【发布时间】:2011-06-26 20:13:49
【问题描述】:
今天我添加了一个类来管理与 MySQL 服务器的连接。它将是多线程的,所以我想使用 mysql++。我下载了最新版本并在调试模式下编译它,没有任何错误。一旦我将编译后的mysqlpp_d.lib 添加到我的解决方案中,当然还有其他要求(mysql 5.0 包含和 lib),我得到了一些链接器错误。
Error 17 error LNK1169: one or more multiply defined symbols found C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxxx\binaries\xxxx.exe 1 1 xxxxx
Error 16 error LNK2005: "public: __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >(int)" (??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z) already defined in xxxxxx.obj C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxxx\trunk\vc10\xxxxx\mysqlpp_d.lib(mysqlpp_d.dll) xxxxxxx
Error 15 error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const " (?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ) already defined in client_context.obj C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxx\trunk\vc10\xxx\mysqlpp_d.lib(mysqlpp_d.dll) xxxxx
Error 14 error LNK2005: "public: void __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::`vbase destructor'(void)" (??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ) already defined in xxxxx.obj C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxx\trunk\vc10\xxxx\mysqlpp_d.lib(mysqlpp_d.dll) xxx
是否有解决这些错误的方法?
顺便说一句:我编译了整个 mysql++ 库而没有更改任何编译配置。
【问题讨论】:
-
您确定您的代码的运行时库设置和您链接的库相同吗? msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
-
是的,都是多线程调试 DLL (/MDd)
-
您能否检查嵌入到您的应用程序中的清单,看看它是否提到了多个运行时?
-
@Bart 我不确定,但清单中没有关于运行时的信息。
标签: c++ mysql linker linker-errors stdstring