0

I'm using VC++ 2010 Ultimate and I'm running a Windows 7 x64 machine.

I have a function declared to be a dll export ( __declspec(dllexport) ) and it builds without error or warning, but when I try to load that function with GetProcAddress it returns NULL. I've looked inside the .exp file VC++ generates and the function is in there, but when I look inside the .dll file it generates the function isn't in there, and I have no idea why.

Also, I can't use implicit linking for this function because this function has to be loaded from more then one seperate DLL.

This is how I'm declaring the function:

DLL_EXPORT void *InterfaceFactory( char *pInterfaceName );

This is how I'm trying to load the function:

HMODULE pDLL = LoadLibrary( "vsys.dll" );
void *pOut = GetProcAddress( pDLL, "InterfaceFactory" );

When I run this code pDLL isn't NULL after I load the DLL so I don't know why it's not able to find InterfaceFactory.

BTW the code for exporting the function and loading the function are in different projects (and DLLs) inside Visual Studio.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by tomtetlaw
0

You forget extern "C" ? Prevents name mangling if I remember right.

try:

extern "C" DLL_EXPORT void *InterfaceFactory( char *pInterfaceName );
0

Oh, I probably should've included that macro. I've defined it as: #define DLL_EXPORT extern "C" __declspec( dllexport )

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.