Thread: Making C DLL using MSVC++ 2005

  1. #16
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    ok lets say we will use dll's then

    in MyProgram.h
    the code goes:
    Code:
    int foo(int *num);
    int foo2(int *gum);
    what do i have to do with these files?
    resource.h
    stdafx.h
    assemblyinfo.cpp
    stdafx.cpp
    Last edited by chico1st; 05-28-2008 at 09:42 AM.

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    assemblyinfo.cpp does not appear in native dlls.
    They ONLY appear in dotNet projects.
    In short, you have the wrong type of project!

    stdafx.cpp/stdafx.h are for PCH, which you can use or ignore. They're very simply to use, really.
    Resource.h is for resources, if you have any. Dialogs, menus, icons, etc.
    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. #18
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    does anyone know how to turn off .NET in MSVC++2005?

    I disabled precompiled headers and deleted stdafx.cpp/stdafx.h/Resource.h
    How am I supposed to setup MyProgram.h? Is it something like

    Code:
    __declspec(export) extern "C" int foo(int *num);
    __declspec(export) extern "C" int foo2(int *gum);
    that is all of my code.. there is nothing else.

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, you must create an appropriate project.
    All native projects, non-dotNet, are located under Win32.

    Also, here's a DLL tutorial:
    http://cboard.cprogramming.com/showp...9&postcount=16
    It's for C++, though, but works fine for C.

    Make SURE you have a proper project!
    Last edited by Elysia; 05-28-2008 at 10:23 AM.
    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. #20
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    ok it turns out to make a Win32 DLL in MSVC++2005 you just make an empty project select DLL application type and start building it from there.

    but i have many errors all of which come from my header. this is it in its entirety
    Code:
    // Error display function
    __declspec(dllexport) void DisplayError(error);
    //
    // Callbacks
    __declspec(dllexport) int AnalogueCardInit(unsigned int *MegaMan);
    __declspec(dllexport) int AnalogueCardClose(int fire);
    __declspec(dllexport) int AnalogueCardGet(int width);

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What errors?
    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. #22
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    Code:
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(6) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(6) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(6) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2059: syntax error : ','
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2059: syntax error : ')'
    EDIT: ok for that to make sense I will have to post the actual functions (im not supposed to :P)
    Code:
    // Error display function
    __declspec(dllexport) void DisplayError(Int32 error);
    //
    // Callbacks
    __declspec(dllexport) int AnalogueCardInit(SessHandle *Sess, InterHandle *Inter, int *Width, int *Height, uInt8 *image1D, uInt8 **image2D);
    __declspec(dllexport) int AnalogueCardClose(SessHandle *Sess, InterHandle *Inter);
    __declspec(dllexport) int AnalogueCardSnap(SessHandle Sid, uInt8 *ImaqBuffer, uInt32 top, uInt32 left, uInt32 height, uInt32 width);
    Last edited by chico1st; 05-28-2008 at 12:52 PM.

  8. #23
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    __declspec(dllexport) void DisplayError(error);

    missing type for the parameter
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  9. #24
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    if i include the data types i get many more errors: I guess i will post those too. I thought it would be good to deal with one set of errors first but that might have been a bad idea
    Code:
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(2) : error C2146: syntax error : missing ')' before identifier 'error'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(2) : error C2061: syntax error : identifier 'error'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(2) : error C2059: syntax error : ';'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(2) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2143: syntax error : missing ';' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2059: syntax error : 'type'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(6) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(6) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(6) : error C2143: syntax error : missing ';' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(6) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2146: syntax error : missing ')' before identifier 'Sid'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2061: syntax error : identifier 'Sess'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2059: syntax error : ';'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2059: syntax error : ','
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(7) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(95) : warning C4142: benign redefinition of type
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(95) : error C2370: 'InterHandle' : redefinition; different storage class
    1>        c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.h(5) : see declaration of 'InterHanle'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1274) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1274) : error C2081: 'InterHandle' : name in formal parameter list illegal
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1274) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1274) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1275) : error C2146: syntax error : missing ')' before identifier 'ifid'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1275) : error C2061: syntax error : identifier 'ifid'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1275) : error C2059: syntax error : ';'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1275) : error C2059: syntax error : ','
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1275) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1326) : error C2146: syntax error : missing ')' before identifier 'ifid'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1326) : error C2061: syntax error : identifier 'ifid'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1326) : error C2059: syntax error : ';'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\niimaq.h(1326) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(113) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(113) : error C2081: 'InterHandle' : name in formal parameter list illegal
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(113) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(113) : error C2059: syntax error : 'type'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(113) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(193) : error C2143: syntax error : missing ')' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(193) : error C2081: 'InterHandle' : name in formal parameter list illegal
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(193) : error C2143: syntax error : missing '{' before '*'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(193) : error C2059: syntax error : ')'
    1>c:\documents and settings\desktop\imaq code\1.0\1.0.2dv3\dlltest\aquisition.c(194) : error C2054: expected '(' to follow 'Inter'
    Last edited by chico1st; 05-28-2008 at 01:04 PM.

  10. #25
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Have you defined all these types:
    Int32, SessHandle, InterHandle, uInt8?
    My guess is you haven't included proper headers because the compiler is (probably) barking at them.
    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. #26
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    wow all 42 errors are gone! Thanks!

    PS: Is your compiler a dog?
    the compiler is (probably) barking at them.

  12. #27
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Is your compiler a dog?
    No, an army sergeant that makes you knock it down when you forget to include headers
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-01-2008, 10: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