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.

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


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

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