Linking DLL with executable (win32)
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!
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 { ... };
class __declspec(dllexport) someclass { ... };
and the definitions you include in your .exe should be like this:
class __declspec(dllimport) someclass { ... };
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement