2011-11-14 6 views
3

정적 라이브러리를 디버깅하는 방법을 배우려하고 있는데 특히 JsonCpp을 수정하려고합니다.정적 라이브러리를 수정하는 방법은 무엇입니까?

나는 Visual Studio에서 출력 창에 링크되는 정확히 상황을 확인하는 데 사용할 수 있습니다 어떤 프로젝트 설정?

============================================== ====================

여기에 오류가 있습니다 :

Error 1 error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" ([email protected]@@[email protected]) already defined in libcpmtd.lib(xlock.obj) msvcprtd.lib 

Error 2 error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" ([email protected]@@[email protected]@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)" ([email protected]@@[email protected]) 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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 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 *)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@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 &)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@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 " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@QBEPBDXZ) already defined in Core.obj msvcprtd.lib 

Error 8 error LNK2005: "public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " ([email protected]_Container_base[email protected]@@QBEXXZ) already defined in Core.obj msvcprtd.lib 

Error 9 error LNK2005: "public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" ([email protected]@@[email protected]) already defined in Core.obj msvcprtd.lib 

Error 10 error LNK2005: "public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" ([email protected]@@[email protected]) 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 *)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@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)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@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 " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@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)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) 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 &)" ([email protected][email protected]@[email protected]@[email protected]) already defined in Serialization.obj msvcprtd.lib 

Error 16 error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" ([email protected][email protected]@[email protected]@SAHXZ) already defined in Serialization.obj msvcprtd.lib 

Error 17 error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" ([email protected][email protected]@[email protected]@[email protected]) 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)" ([email protected]@@[email protected]) already defined in LIBCMTD.lib(stdexcpt.obj) MSVCRTD.lib 

Error 21 error LNK2005: "public: __thiscall std::exception::exception(void)" ([email protected]@@[email protected]) already defined in LIBCMTD.lib(stdexcpt.obj) MSVCRTD.lib 

Error 22 error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" ([email protected]@@[email protected]@@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 &)" ([email protected]@@[email protected]@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 &)" ([email protected]@[email protected]@@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 &)" ([email protected]@[email protected]@@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 

답변

3

동일한 라이브러리의 서로 다른 두 버전을 함께 연결하는 것이 문제입니다. 라이브러리가 표준 C 라이브러리의 디버그 단일 스레드 버전에 정적으로 링크되어있는 경우 해당 라이브러리를 사용하는 응용 프로그램은 동일한 런타임 라이브러리의 다중 스레드 버전 릴리스에 동적으로 링크 할 수 없습니다. 메모리를 하나 할당하지만 다른 반환되는 경우

그렇지 않으면, 당신은 함께 예를 들어, 두 개의 서로 다른 메모리 할당 자 및 신체 상해를 바람. 따라서 링커가이를 허용하더라도 응용 프로그램은 라이브러리와 안전하게 상호 운용 될 수 없으므로 어떤 점이 있습니까?

라이브러리가 이미 정적 표준 C 라이브러리의 멀티 쓰레드 버전으로 연결되어 있으며 응용 프로그램이 동적으로 단일 스레드 버전으로 연결하자. 라이브러리가 응용 프로그램에 의해 할당 된 객체의 delete을 호출하고 라이브러리의 할당자가 객체를 할당하지 않았는데도 객체를 해제해야한다면 어떻게됩니까?

이 작업을 안정적으로 수행 할 수있는 방법이 없습니다. 모든 것을 똑같은 정적 라이브러리에 정적으로 링크하거나 모든 것을 동적으로 링크하십시오. (이것은 기본적으로 동적 연결이 선호되는 이유입니다. 그렇지 않으면 모든 라이브러리와 응용 프로그램을 동시에 연결해야합니다. 또는 매우주의해야합니다.) 기호가 충돌하여 경고를 받았다고 생각해보십시오.

+0

이 정적 라이브러리 수정의 요지는 무엇입니까? 나는 근원을 고칠 수있다. –

+0

그런 다음 프로젝트를 사용하는 것과 동일한 표준 C 라이브러리를 사용하도록 컴파일하고 같은 방법으로 연결하십시오. 프로젝트가 멀티 스레드 릴리스 표준 C 라이브러리에 동적으로 링크하는 경우 동일한 방식으로 링크하도록 라이브러리를 다시 컴파일하십시오. (내 마지막 단락의 두 번째 문장을 참조하십시오.) –

+0

내 질문에 대답하는 방법을 정말 볼 수 없어, 귀하의 배려 감사하지만 그냥 정적 라이브러리를 빌드하는 데 사용 된 소스 디버깅 방법을 찾고 있습니다. 두 개의 프로젝트가 있습니다. 하나의 프로젝트는 내 주요 실행 파일이고 다른 하나는 (내 실행 프로젝트에서 사용되는) 정적 라이브러리입니다. –

관련 문제