1

Today I added a class which manages the connection to a MySQL Server. It will be multi-threaded, so I want to use mysql++. I downloaded the newest version and compiled it in debug mode without any errors. Once I added the compiled mysqlpp_d.lib to my solutions, and of course the other requirements too (mysql 5.0 include and lib), I got some linker errors.

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

Is there a solution for these errors?

BTW: I compiled the whole mysql++ libary without changing any compile configurations.

Gaffi
  • 4,307
  • 8
  • 43
  • 73
Aurus
  • 705
  • 9
  • 21
  • Are you certain that the runtime library settings for your code and the libraries you link in are the same? http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx – Bart Jun 26 '11 at 20:20
  • yes, both are Multi-threaded Debug DLL (/MDd) – Aurus Jun 26 '11 at 20:35
  • Could you check the manifest that is being embedded into your application and see if it mentions multiple runtimes? – Bart Jun 26 '11 at 22:42
  • @Bart I'm not sure but there is no information about runtimes given in the manifest. – Aurus Jun 27 '11 at 10:04

2 Answers2

1

Define MYSQLPP_NO_DLL in Project Properties->C/C++/Preprocessor

Izzy
  • 402
  • 6
  • 16
0

Try setting /NODEFAULTLIB parameter in project options -> Linker/Input

Ulterior
  • 2,786
  • 3
  • 30
  • 58