MSVC ++ 2008 проблема с компоновщиком и DLL - PullRequest
1 голос
/ 26 декабря 2010

Я пишу некоторые DLL, которые используют проект xmlrpc-c (http://xmlrpc -c.sourceforge.net / ).Я скачал и скомпилировал xmlrpc-c, используя MSVC ++ 2008.С настройками:

xmlrpc-c building settings

Теперь я пытаюсь собрать свою dll и связать ее с xmlrpc-c.Я использую настройки: dll building settings

Я получаю ошибки компоновщика:

------ Build started: Project: [...], Configuration: Debug Win32 ------
Linking...
msvcprtd.lib(MSVCP90D.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 xmlrpccppD.lib(value.obj)
msvcprtd.lib(MSVCP90D.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 xmlrpccppD.lib(value.obj)
msvcprtd.lib(MSVCP90D.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 xmlrpccppD.lib(value.obj)
msvcprtd.lib(MSVCP90D.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 xmlrpccppD.lib(value.obj)
LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __malloc_dbg already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __encoded_null already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(sprintf.obj) : error LNK2005: _sprintf already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(strftime.obj) : error LNK2005: _strftime already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(getenv.obj) : error LNK2005: _getenv already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(strtol.obj) : error LNK2005: _strtol already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(strtoq.obj) : error LNK2005: __strtoui64 already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(_file.obj) : error LNK2005: ___iob_func already defined in MSVCRTD.lib(MSVCR90D.dll)
LIBCMTD.lib(strnicmp.obj) : error LNK2005: __strnicmp already defined in MSVCRTD.lib(MSVCR90D.dll)
   Creating library [...].lib and object [...].exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
[...].dll : fatal error LNK1120: 1 unresolved externals
Build log was saved at "[...]\Debug\BuildLog.htm"
[...] - 34 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Я пытался добавить опции компоновщика:

/NODEFAULTLIB:MSVCRTD
/NODEFAULTLIB:LIBCMTD

Но этотакже дают странные перезапуски.

Я подозреваю, что разные библиотеки времени выполнения вызывают проблемы (отладка MT и отладка MT DLL).

Как это исправить?

1 Ответ

9 голосов
/ 26 декабря 2010

Библиотеки времени выполнения отличаются: многопоточная отладочная DLL от многопоточной отладки. Они должны быть одинаковыми.

...