Skip to main content
GameDev.net gamedev.net
🔒 Locked 🤖 Godot

Dynamic lib using a static lib (VC++ .NET)

Started by cstdio Sep 22, 2005 at 2:45 PM 0 replies 1.9k views
Original Post
cstdio
cstdio
Hi all. I'm trying to use a static lib (a game engine) within a dynamic lib (a DirectShow filter) and I'm getting a wealth of LNK2005 errors. I've never run into this problem before without being able to fix it. Usually it's a simple matter of making sure that both libs are multi-threaded or forcing the linker to ignore a few libs, but so far I haven't been able to get anything to work. The static lib is multi-threaded and the dynamic lib is multi-threaded dll. I'd appreciate any help/wisdom you can offer. Worse case, I'll hack the engine into a dll and give that a shot...but I'd like to avoid that unless absolutely necessary. VS gives me this garbage output: Linking... msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in GraphicsEngine.lib(Engine.obj) [SNIP: more msvcptr.lib LNK2005 errors] msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in GraphicsEngine.lib(Logger.obj) msvcprt.lib(MSVCP71.dll) : error LNK2005: "public: void __thiscall std::basic_ostream >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in GraphicsEngine.lib(Logger.obj) libcmt.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall exception::exception(class exception const &)" (??0exception@@QAE@ABV0@@Z) already defined in msvcrt.lib(MSVCR71.dll) libcmt.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall bad_cast::bad_cast(char const *)" (??0bad_cast@@QAE@PBD@Z) already defined in msvcrt.lib(MSVCR71.dll) libcmt.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall bad_cast::bad_cast(class bad_cast const &)" (??0bad_cast@@QAE@ABV0@@Z) already defined in msvcrt.lib(MSVCR71.dll) [SNIP: more libcpmt.lib LNK2005 errors] libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprt.lib(MSVCP71.dll) msvcprt.lib(MSVCP71.dll) : warning LNK4006: "public: __thiscall std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in GraphicsEngine.lib(Engine.obj); second definition ignored [SNIP: more "ignoring redefinition" warnings] Creating library .\Release/PushSource.lib and object .\Release/PushSource.exp libcmt.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup Release/PushSourceOpenGL.dll : fatal error LNK1120: 1 unresolved externals Build log was saved at "xxx\BuildLog.htm" PushSourceOpenGL - 63 error(s), 61 warning(s) ---------------------- Done ---------------------- Build: 2 succeeded, 1 failed, 0 skipped
trevaaar
trevaaar
It looks like the problem is that your static lib already contains implementations of the standard C++ classes (like std::string) compiled into it, while those same classes are defined inside msvcprt. You would have to either change your static library to use Multithreaded DLL or change your DLL to using Multithreaded. Note that static libraries can still use Multithreaded DLL and DLLs can still use Multithreaded.

Topic Locked

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

Sign in to reply to this topic.