VC++ DLL problem

Started by
3 comments, last by Yohomyth 20 years ago
I''m still having a problem with explicitly linking DLLs. //DLL source: #include <iostream.h> void __declspec(dllexport) abc() { cout << "abc"; } //EXE source #include <windows.h> int main() { HMODULE hDLL = LoadLibrary("dll.dll"); void (*abc)() = GetProcAddress(hDLL,"abc"); abc(); FreeLibrary(hDLL); return 0; } Whenever I try this the program freezes. I debugged it and it turns out that the value of abc is 0x0000. Does anyone know what i''m doing wrong? Here comes the Thnikkaman!
------------------------------------------------------------"Many combilations elizagerth. I hope you see my particles." - Senor Cardgage
Advertisement
Is LoadLibrary() completing succesfully? Try checking the return value. And remember GetLastError() is your friend.
put extern "C" around the abc function.

//DLL source:#include <iostream.h>extern "C"{void __declspec(dllexport) abc(){ cout << "abc"; }} 
THX!!! That extern "C" finally made it work! I''ve had this problem for a long time...





Here comes the Thnikkaman!
------------------------------------------------------------"Many combilations elizagerth. I hope you see my particles." - Senor Cardgage
Make sure you fully understand why the extern "C" worked - might save you some headache in the future
People fear what they don''t understand, hate what they can''t conquer!

This topic is closed to new replies.

Advertisement