Making C DLL using MSVC++ 2005

This is a discussion on Making C DLL using MSVC++ 2005 within the C Programming forums, part of the General Programming Boards category; Is there a way to make a C DLL using MSVC++ 2005? when i make a project MSVC immeadiatly makes ...

  1. #1
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168

    Making C DLL using MSVC++ 2005

    Is there a way to make a C DLL using MSVC++ 2005? when i make a project MSVC immeadiatly makes all c++ files.

    ie/
    Code:
    // TestDLL.h
    #pragma once
    using namespace System;
    namespace TestDLL {
    	public ref class Class1
    	{
    		// TODO: Add your methods for this class here.
    	};
    }
    <if this one isnt in c++ (its hard to tell since i dont actually know c++) there are many other files that are>

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    This is C++/CLI.
    Make a new project and select win32 -> console application.
    You can then enter project -> compiler -> advanced -> compile as -> C.
    (Or rename files to .c, which might be better and less confusing.)
    Or you could compile them as C++, but write C.
    Last edited by Elysia; 05-27-2008 at 01:20 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    but if i make a C console application how do i make a dll?

    if i compile as c++ will my c code be ok?

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Oh right, sorry.
    You may choose a win32 application and select dll in the wizard.
    C++ is backwards compatible with C, but may require some extra things like casts and avoiding reserved keywords, but otherwise it will compile C code fine.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    if i compile as c++ can it use uInt32? and things like that?

    im getting all sorts of crazy errors

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Those errors aren't C vs C++ related at all. It means you probably forgot to include a correct header.
    I don't know of a type "uInt32" however. But I do know of uint32_t (http://en.wikipedia.org/wiki/stdint.h).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    i am getting wierdo errors like
    Code:
    1> error C3861: 'malloc': identifier not found
    AND
    error C3861: 'memset': identifier not found
    AND
    error C2872: 'Int32' : ambiguous symbol
    could be 'c:\documents and settings\desktop\1.0\1.0.2d\imaqaquisition\niimaq.h(72) : long Int32'
    or 'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Int32'

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Sounds to me like you have the wrong type of project.
    Goto File -> New -> Project -> Win32 -> Win32 Project and select DLL.
    Include "stdlib.h" to get malloc and "memory.h" for memset.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    when i add these include files which files do i include them in ..
    I know how to do this is a console application but with dll there is also

    MyProgram.h
    resource.h
    stdafx.h
    assemblyinfo.cpp
    stdafx.cpp

    I also need to include Library.lib, Headerfile.h

    As of now i just have
    include "headerfile.h" in all of the files :P
    Last edited by chico1st; 05-27-2008 at 02:49 PM.

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    As I said, you're using dotNet.
    Redo your projects with Win32.
    And header files... well, you should know how to code C, shouldn't you? Otherwise you may have to get a book. C isn't exactly trivial.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    what if i make a static library instead of a dll? Can i call that from other programs?

    DLL's are complicated and this may be easier with no loss?

    Only one program will be using this library at a time.

    If i chose Win32 i dont get the option to make a DLL... only Static or console program :S
    I know how to make console projects but when there are all these extra files i get confused.. i know i dont have to put my includes in all of those 'extra' files
    Last edited by chico1st; 05-27-2008 at 02:52 PM.

  12. #12
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    > "memory.h" for memset.

    string.h, not memory.h.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Quote Originally Posted by chico1st View Post
    what if i make a static library instead of a dll? Can i call that from other programs?
    Yes, you can.

    DLL's are complicated and this may be easier with no loss?
    Dlls are not complicated at all.

    If i chose Win32 i dont get the option to make a DLL... only Static or console program :S
    I know how to make console projects but when there are all these extra files i get confused.. i know i dont have to put my includes in all of those 'extra' files
    Well, that's weird. I certainly get the option to create Windows App, Console App, Dll and Static Library.
    And what other files? Stdafx.cpp, stdafx.h, and maybe some other?

    Quote Originally Posted by robwhit View Post
    > "memory.h" for memset.
    string.h, not memory.h.
    Alright. Good correction. MSDN says either memory.h or string.h.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    Are Static.lib files supposed to have Static.h files associated with them like Dynamic.dll files are supposed to have Dynamic.h files?

    When I made my Static library project in MSVC it didnt make one so i didnt either.

  15. #15
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    I have never made a static library.
    There is no "Dynamic.h" file for dlls.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-01-2008, 09:09 AM
  2. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  3. memcpy working strangely in msvc 2005
    By *DEAD* in forum C++ Programming
    Replies: 1
    Last Post: 06-15-2007, 09:50 AM
  4. Error C2664 - Trying to call an external Dll
    By jamez05 in forum C++ Programming
    Replies: 3
    Last Post: 08-08-2006, 06:07 AM
  5. Replies: 1
    Last Post: 09-18-2005, 09:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21