今天,我添加了一个管理到MySQL服务器的连接的类。它将是多线程的,所以我想使用mysql++。我下载了最新的版本,并在调试模式下编译它,没有任何错误。一旦我将编译好的mysqlpp_d.lib添加到我的解决方案中,当然还有其他需求(MySQL5.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++库,没有更改任何编译配置。
发布于 2012-02-13 18:16:09
在“项目属性”->“C/C++/预处理器”中定义MYSQLPP_NO_DLL
发布于 2011-07-12 07:02:13
尝试在项目选项->链接器/输入中设置/NODEFAULTLIB参数
https://stackoverflow.com/questions/6486447
复制相似问题