Linker problem with mysql++ library


#1

I have add mysql++ library and when I try to link my app I get the following errors:

MainComponent.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits > & __thiscall std::basic_ostream<char,struct std::char_traits >::flush(void)” (_imp?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) referenced in function “public: __thiscall std::basic_ostream<char,struct std::char_traits >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits > &)” (??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@AAV12@@Z)
MainComponent.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: void __thiscall std::basic_ostream<char,struct std::char_traits >::_Osfx(void)” (_imp?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) referenced in function “public: __thiscall std::basic_ostream<char,struct std::char_traits >::sentry::~sentry(void)” (??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ)
MainComponent.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: void __thiscall std::basic_ios<char,struct std::char_traits >::setstate(int,bool)” (_imp?setstate@?$basic_ios@DU?char_traits@D@std@@@std@@QAEXH_N@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (???6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)

If I comment out the mysql stuff and the mysql++ include then it compiles okay. Any idea what lib I am missing for this stuff?


#2

[quote]I’m getting link errors. Help!

You’re probably not linking to the MySQL client library (libmysqlclient.* on Unixy systems, libmysql.lib on Windows). You have to do that as well as link to the MySQL++ library. Study the examples’ Makefiles or project files (as appropriate for your platform) to see how this is done.

Visual C++: An additional requirement with Visual C++ is that you must link to the same C Run-Time Library (RTL) for all modules throughout your project. As of MySQL++ 1.7.16, the library is built using the multithread DLL version of the C RTL. If you link MySQL++ to a program or additional third party library that uses a different RTL, you will get link errors. Again, study the example projects’ settings to see how this is done.[/quote]

From the MySQL++ FAQ. I don’t know if you’ve seen this or not, but it’s probably worth looking into.


#3

Hi aciddragon I was wondering if you managed to solve the linking problem as I’m getting the same link errors!! what could be causing it?

if I comment out the line

then it compiles ok.

I have looked over the project settings for the example projects and my apps project settings are the same, but does not link properly.


#4

No I have not been able to solve it, I have just reverted to using the standard/native mysql libraries. That works well for me, it is as easy to use as the mysql++, it is however more c like than c++, but it works.


#5

Are you absolutely sure your project uses Multithreaded Debug DLL? There’s also a Multithreaded Debug option (with no DLL). I tried it with that, and I got a little farther in the build. After that I had to tell it to ignore the default msvcrtd.lib library, and that resulted in a successful build that was able to connect to a database.


#6

Mine compiles with Juce and mysql++ libraries quite happily without ignoring any libraries. Run Time libraries (for debug) set to use Multithreaded Debug. Works fine without the DLL ones.


#7

yep, you have to rebuild mysql++ library with only multithreaded without the dll, this will build the new runtime library files as well as a new dll that needs to reside with your exe, working ok now :wink:


#8

By default, juce uses the non-dll libs, but I guess you could rebuild it to use the same ones as mysql - I guess it’s just a case of choosing whether it’s less hassle to rebuild juce or mysql.


#9