Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Yohomyth

VC++ DLL problem

This topic is 5164 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
Is LoadLibrary() completing succesfully? Try checking the return value. And remember GetLastError() is your friend.

Share this post


Link to post
Share on other sites
put extern "C" around the abc function.


//DLL source:

#include <iostream.h>

extern "C"
{
void __declspec(dllexport) abc()
{ cout << "abc"; }
}

Share this post


Link to post
Share on other sites
THX!!! That extern "C" finally made it work! I''ve had this problem for a long time...





Here comes the Thnikkaman!

Share this post


Link to post
Share on other sites
Make sure you fully understand why the extern "C" worked - might save you some headache in the future

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!