
Dynamic Linking DLL problem
I made a DLL and I load it succefully using static linked
dlls (by .lib). So the dll is ok.
Now I try to load it using dynamic linking. First I use
LoadLibrary and it returns to me a valid handle =
0x10000000
But when I get to GetProcAddress it returns NULL. The
function exists in the dll but it return NULL.
Here is the code I use to generate the dll:
print.cpp
#include <iostream.h>
__declspec(dllexport) void MyPrint()
{
cout << "Hello this is a DLL" << endl;
Quote:
}
And here is the loading code
main.cpp
#include <windows.h>
HINSTANCE handle;
typedef void (*FuncPtr)();
int main()
{
FuncPtr funcpointer;
handle=LoadLibrary("DLLBuilder.dll");
funcpointer=(FuncPtr)GetProcAddress(handle,"MyPrint");
funcpointer();
FreeLibrary(handle);
return 0;
Quote:
}
////
when it reach funcpointer() exit with an error (of course
because funcpointer == NULL). What I'm doing wrong
because handle is valid and "MyPrint"is the true name.
I heard that with some compilers I has to refer
the "MyPrint" as "_MyPrint" but it doesn't work any way.
did I miss something?
thanks in advance
Frank