• Advertisement
Sign in to follow this  

Linking DLL with executable (win32)

This topic is 4611 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

Hello, I'll start with a simple example that shows what is my problem about. Ok, here is one class that must be exported from dll: class __declspec(dllexport) someclass { ... }; The name of dll is library.dll. I compile and link it like this: icl -c -nologo -O2 -EHsc library.cpp link library.obj -dll And here we go, I have nice library.dll and import library - library.lib. Now I make executable that uses this dll: #include <someclass.h> int main(){ someclass * x = new someclass; x->dosomething(); } icl main.cpp -c -nologo -O2 -EHsc link main.obj library.lib Everything is ok: executable works fine, excepted one thing. When I link main.obj, linker tells that main.lib import library generated.. and yes, impdef or bindump tells that main.exe exports the same symbols as library.dll. Why is this so? I think main.exe shouldn't export any symbols. Am I missing something? If there are any compiler/linker options to fix this issue, I whould appreciate if you give me some feedback :) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
The definitions you use in your dll should be like this:

class __declspec(dllexport) someclass { ... };

and the definitions you include in your .exe should be like this:

class __declspec(dllimport) someclass { ... };

Share this post


Link to post
Share on other sites
Thank you very much for your reply :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement