Sign in to follow this  
dac

Linking DLL with executable (win32)

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this