Unc3nZureD
Unc3nZureD

Reputation: 194

Problems with linking static libraries

There's a main project which is written in VC2008, I can't change it. I'd like to write a LIB file which I'd like to use in that project.

I'd like to write this LIB file in VS2013, but I think it would be incompatible. That's why I tried to compile it with VS2008 Toolset (Yes, I have it installed, but I don't want to use that IDE).

So, all in one: Main project: VS2008 LIB Project: VS2008 Toolset from 2013

When I compile my LIB in the 2008 IDE, it perfectly works with my main project, but if I compile it from 2013, with toolset I can't compile the main project, because of the following errors:

1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _sprintf already defined in LIBCMT.lib(sprintf.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _strstr already defined in LIBCMT.lib(strstr.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: ___iob_func already defined in LIBCMT.lib(_file.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _strchr already defined in LIBCMT.lib(strchr.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _system already defined in LIBCMT.lib(system.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _vsprintf_s already defined in LIBCMT.lib(vsnprnc.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _tolower already defined in LIBCMT.lib(tolower.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _fopen already defined in LIBCMT.lib(fopen.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: __strdup already defined in LIBCMT.lib(strdup.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _fwrite already defined in LIBCMT.lib(fwrite.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _freopen already defined in LIBCMT.lib(freopen.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _strcat_s already defined in LIBCMT.lib(strcat_s.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _fclose already defined in LIBCMT.lib(fclose.obj)
1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) already defined in libcpmt.lib(uncaught.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "protected: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Myptr(void)const " (?_Myptr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IBEPBDXZ) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::rfind(char const *,unsigned int,unsigned int)const " (?rfind@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z) already defined in gamelib.lib(ActorInstanceData.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::~basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(void)" (??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ) already defined in eterlib.lib(GrpTextInstance.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@ABV01@@Z) already defined in eterlib.lib(GrpTextInstance.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::substr(unsigned int,unsigned int)const " (?substr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV12@II@Z) already defined in PythonSkill.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_last_of(char const *,unsigned int)const " (?find_last_of@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDI@Z) already defined in PythonSkill.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::length(void)const " (?length@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::_String_iterator<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::end(void)" (?end@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE?AV?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ) already defined in MovieMan.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::_String_iterator<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::begin(void)" (?begin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE?AV?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ) already defined in MovieMan.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(char const *)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in InstanceBaseEffect.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in InstanceBaseEffect.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(int)" (?width@ios_base@std@@QAEHH@Z) already defined in eterpack.lib(EterPack.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBEHXZ) already defined in eterpack.lib(EterPack.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in eterpack.lib(EterPack.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in eterpack.lib(EterPack.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: int __thiscall std::ios_base::rdstate(void)const " (?rdstate@ios_base@std@@QBEHXZ) already defined in eterpack.lib(EterPack.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in cryptlib-5.6.1MT.lib(integer.obj)
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in InstanceBase.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: static int __cdecl std::char_traits<char>::compare(char const *,char const *,unsigned int)" (?compare@?$char_traits@D@std@@SAHPBD0I@Z) already defined in InstanceBaseEffect.obj
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq(char const &,char const &)" (?eq@?$char_traits@D@std@@SA_NABD0@Z) already defined in gamelib.lib(ActorInstanceData.obj)
1>LIBCMT.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Release/metin2client.exe : fatal error LNK1169: one or more multiply defined symbols found

I've got no idea what these error message mean (Well probably the VS2013 included basic functions too, whiches are part of VS2008, but why? and how to solve?).

Could anyone help me, how could I resolve this error?

Thank you!

Upvotes: 0

Views: 4391

Answers (2)

Unc3nZureD
Unc3nZureD

Reputation: 194

Answered by: Joachim Pileborg Forgot to set the LIB settings to Multi-Threaded instead of Multi-Threaded DLL. Thank you.

Upvotes: 1

Khouri Giordano
Khouri Giordano

Reputation: 1461

It looks like your lib has hit a #pragma comment(lib,"msvcp90.lib") which can be countered with a /nodefaultlib linker option, but then you may have to supply the list of libraries to link with.

Upvotes: 0

Related Questions