Wie zu beheben eine Statische Bibliothek?
Ich versuche zu lernen, wie zu Debuggen, statische Bibliotheken, und ich bin versucht zu reparieren, JsonCpp im besonderen.
Was Projekt-Einstellungen kann ich verwenden, um zu sehen, was genau verknüpft wird das Ausgabefenster in Visual Studio?
==================================================================================
Hier sind die Fehler, die ich immer bin:
Error 1 error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in libcpmtd.lib(xlock.obj) msvcprtd.lib
Error 2 error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in libcpmtd.lib(xlock.obj) msvcprtd.lib
Error 3 error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) already defined in libcpmtd.lib(stdthrow.obj) msvcprtd.lib
Error 4 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 Core.obj msvcprtd.lib
Error 5 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 Core.obj msvcprtd.lib
Error 6 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 Core.obj msvcprtd.lib
Error 7 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 Core.obj msvcprtd.lib
Error 8 error LNK2005: "public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " (?_Orphan_all@_Container_base_secure@std@@QBEXXZ) already defined in Core.obj msvcprtd.lib
Error 9 error LNK2005: "public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (??1_Container_base_secure@std@@QAE@XZ) already defined in Core.obj msvcprtd.lib
Error 10 error LNK2005: "public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (??0_Container_base_secure@std@@QAE@XZ) already defined in Core.obj msvcprtd.lib
Error 11 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 libcpmtd.lib(locale0.obj) msvcprtd.lib
Error 12 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> >(unsigned int,char)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ID@Z) already defined in Serialization.obj msvcprtd.lib
Error 13 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 Core.obj msvcprtd.lib
Error 14 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 Serialization.obj msvcprtd.lib
Error 15 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 Serialization.obj msvcprtd.lib
Error 16 error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in Serialization.obj msvcprtd.lib
Error 17 error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in Core.obj msvcprtd.lib
Error 18 error LNK2005: _malloc already defined in LIBCMTD.lib(dbgmalloc.obj) MSVCRTD.lib
Error 19 error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj) MSVCRTD.lib
Error 20 error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj) MSVCRTD.lib
Error 21 error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj) MSVCRTD.lib
Error 22 error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMTD.lib(stdexcpt.obj) MSVCRTD.lib
Error 23 error LNK2005: _strchr already defined in LIBCMTD.lib(strchr.obj) MSVCRTD.lib
Error 24 error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj) MSVCRTD.lib
Error 25 error LNK2005: __CrtDbgReportW already defined in LIBCMTD.lib(dbgrptw.obj)
MSVCRTD.lib
Error 26 error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj) MSVCRTD.lib
Error 27 error LNK2005: _memmove_s already defined in LIBCMTD.lib(memmove_s.obj) MSVCRTD.lib
Error 28 error LNK2005: _sprintf already defined in LIBCMTD.lib(sprintf.obj) MSVCRTD.lib
Error 29 error LNK2005: _sprintf_s already defined in LIBCMTD.lib(sprintf.obj) MSVCRTD.lib
Error 30 error LNK2005: _strpbrk already defined in LIBCMTD.lib(strpbrk.obj) MSVCRTD.lib
Error 31 error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj) MSVCRTD.lib
Error 32 error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj) MSVCRTD.lib
Warning 33 warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library Afterfuture Game Engine
Error 34 fatal error LNK1169: one or more multiply defined symbols found C:\Users\Blake\Desktop\Afterfuture\Afterfuture Game Engine\Debug\Afterfuture Game Engine.exe
InformationsquelleAutor James Linden | 2011-11-14
Du musst angemeldet sein, um einen Kommentar abzugeben.
Das problem ist, dass Sie die Verbindung von zwei verschiedenen Versionen der gleichen Bibliothek. Wenn eine Bibliothek ist statisch gelinkt, um die debug -, single-threaded-version von der standard-C-Bibliothek, eine Anwendung, die die Bibliothek nicht dynamisch-link zu den release, multi-threaded-version der gleichen Laufzeit-Bibliothek.
Andernfalls Sie wind mit, zum Beispiel, zwei verschiedene memory-allocators und Chaos, wenn der Speicher zugeordnet ist, von der man aber wieder an die anderen. Also selbst wenn der linker erlaubt Ihnen, dies zu tun, wird die Anwendung konnte nicht sicher die Zusammenarbeit mit der Bibliothek sowieso-also, was wäre der Punkt?
Nehme an, die Bibliothek ist bereits statisch verknüpft mit der Multithread-version der standard-C-Bibliothek und die Anwendung dynamisch verknüpft, um die single-threaded-version. Was passiert, wenn die Bibliothek ruft
delete
auf ein Objekt, das zugewiesen wurde, die von der Anwendung und der Bibliothek der Zuweisung ist ein Objekt freigeben trotz nie zugeordnet haben?!Es gibt einfach keinen Weg, um diese Arbeit zuverlässig. Statisch-link alles, was, die genau die gleiche statische Bibliothek oder dynamisch-link alles. (Dies ist im Grunde der Grund, dynamic-Verknüpfung ist bevorzugt. Andernfalls muss der link alle Bibliotheken und die Anwendung zur gleichen Zeit oder sein sehr vorsichtig.) Betrachten Sie sich glücklich, die Symbole kollidierte und Sie bekam eine Verwarnung.
Dann einfach kompilieren zu verwenden die gleichen standard-C-Bibliothek Ihr Projekt verwendet und link, um es auf die gleiche Weise. Wenn Ihr Projekt dynamisch links zu den multi-threaded-Version standard-C-Bibliothek kompilieren der Bibliothek zu verknüpfen, die gleiche Weise. (Siehe den zweiten Satz in meinem letzten Absatz.)
Ich weiß nicht wirklich sehen, wie das beantwortet meine Frage, ich schätzen Sie Ihre Rücksicht, aber ich bin gerade auf der Suche nach Methoden, debugging-Quelle, die verwendet wurde, zu bauen, die statische Bibliothek. Ich habe zwei Projekte, ein Projekt ist mein Hauptprogramm und die andere ist meine statische Bibliothek (die ist von meinem ausführbares Projekt).
Es ist nichts falsch mit der Quelle. Das problem ist die Vernetzung. Müssen Sie neu erstellen die statische Bibliothek, indem Sie diese mit der gleichen version der C-standard-Bibliothek, wie Sie verknüpfen Ihr Projekt (Multithreading, DLL). Gibt ' s nichts zu Debuggen. Sie brauchen nur zu verknüpfen, dass die Bibliothek, so ist es mit der gleichen C-Bibliothek Ihre Anwendung ist.
Umbau-und re-linking noch immer produziert den gleichen Fehler.
InformationsquelleAutor David Schwartz