Jump to content
  • Advertisement
Sign in to follow this  
NumberXaero

Need Help: Dynamic/Static Lib building

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

Alright, Im building a dll, in this dll I have one class (call it class A) that makes use of another class that is passed into it (class B). I have a static lib which class B is a part of. Now, the static lib builds fine and class B is used in the app (W32). Class B is initialized in the app, then passed into the class A (the dll class, which I get an instance of through GetProcAddress on a exported DLL function, that works). But, the only way I can get the DLL to build is if I have the classB.h/classB.cpp added to the DLL project. If I set the DLL project dependencies to use the static lib (where class B is) and just include the header for class B, I get the errors below. In short, put class B in static Lib, #include B in DLL project, get errors. Add classB.h/classB.cpp to DLL project, works. Ive been building the DLL by Adding the source file for B, Id like to use B through the static lib. Can anyone help me with this, or tell whats wrong and what to change, thanks. classA.cpp Linking... libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in classBstaticlib Lib.lib(classB.obj) libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in classBstaticlib Lib.lib(classB.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __exitflag already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __wenviron already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___initenv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __environ already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___wargv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___argv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___argc already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __winminor already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __winmajor already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __winver already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __osver already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __osplatform already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __umaskval already defined in LIBCMTD.lib(crt0dat.obj) libcpmtd.lib(xlock.obj) : warning LNK4006: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in classBstaticlib Lib.lib(classB.obj); second definition ignored libcpmtd.lib(xlock.obj) : warning LNK4006: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in classBstaticlib Lib.lib(classB.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __cinit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: _exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __cexit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __c_exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __exitflag already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __wenviron already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___initenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __environ already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___wargv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argc already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __winminor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __winmajor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __winver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __osver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __osplatform already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __umaskval already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored Edit: Ive read/heard something about multi-threading having to do with this, but Im not using multiple threads and as far as I know, none of the libs for it either.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Ive read/heard something about multi-threading having to do with this, but Im not using multiple threads and as far as I know, none of the libs for it either.


you mean multithreaded dll?

[project] | properties | general configeration | c/c++ | code generation | runtime library

Share this post


Link to post
Share on other sites
try changeing

[project] | properties | general configeration | c/c++ | code generation | runtime library

to multithread dll

just try it

Share this post


Link to post
Share on other sites
Im on .Net 2003 but that section only has .exe, .dll, .lib, makefile, utility for me, and its currently DLL. I can build it fine, just not the way I want to, using the lib, instead of adding the files.

Share this post


Link to post
Share on other sites
Cool, seem to have got it working.
For anyone who might search for this problem when the search is fixed. Under .Net 2003 compiler

[Project] -> [Build Properties] -> [Configuration Properties] -> [C\C++] -> [Code Generation], Run-Time library was set to "multi-threaded debug" for my DLL project (no idea why/how it was set to that way) and the other static lib in the solution which the DLL was using, had Run-Time library set to "single-threaded debug" so they needed to match is seems.

Thanks guys for your help. mike25025 when I seen you write
"[project] | properties" and not "[project] | build properties" I figured you were telling me how to do it under VC++6, so my third post or so doesnt make sense. Thanks for help.

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!