-
dll issue
Hi,
I am trying to call functions from a dll without any success.
This is the dll setup:
Code:
#define DllExport __declspec( dllexport )
DllExport int _stdcall setupConnection(void) {
...
}
.def file contains
LIBRARY communication
EXPORTS
setupConnection @1
in my main program, I set up a pointer to that function as follows:
Code:
typedef int (CALLBACK* communication_setup)(void);
communication_setup comSetup;
cDLL = LoadLibrary("communication"); /*Try to open the dll*/
comSetup = (communication_setup)GetProcAddress(cDLL,"setupConnection");
Load library works fine. I checked that the code actually goes into the DLLMain function. For some reason the GetProcAddress returns NULL. I also compiled the calling application and the dll using debug mode in ms vs 2005. I am at a lost here. If anybody has an explanation, I'd really appreciate it. Thanks
Amish
-
Figured it out. It would seem that ms vs 2005 was not using the def file when linking the dll. Most probably name mangling was occuring. After forcing it to use the def file using PROPERTIES->LINKER->INPUT, it worked fine.
Amish