Skip to main content
gamedev.net
🔒 Locked

Need Help: Dynamic/Static Lib building

Started by NumberXaero Jan 5, 2005 at 10:15 PM 5 replies 1.8k views
Original Post
NumberXaero
NumberXaero
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.
mike25025
mike25025
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
NumberXaero
NumberXaero
ok, sure. But im not doing anything with multi-threading so I dont think that it has anything to do with it.
mike25025
mike25025
try changeing

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

to multithread dll

just try it
NumberXaero
NumberXaero
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.
owl
owl
try removing LIBCMTD.lib from the DLL project, or the LIB project.
[size="2"]I like the Walrus best.
NumberXaero
NumberXaero
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.