I'm using Connector C++ 1.1.3 on Win 8 with VS 2010 Express.
For my debug build in Linker->General->Additional Library Directories I have: C:\Program Files\MySQL\Connector C++ 1.1.3\lib\debug
In Linker->Input I have: mysqlcppconn.lib
I get linker error: Server.obj : error LNK2019: unresolved external symbol _get_driver_instance referenced in function "public: bool __thiscall Server::Init(void)" (?Init@Server@@QAE_NXZ)
I have boost in additional include directorys : C:\Users\MyName\Downloads\boost_1_55_0\boost_1_55_0
I would assume get_driver_instance() is defined in the mysqlcppconn.lib.
#include
#include
#include
#include
class Server
{
private:
sql::Driver* sqlDriver;
sql::Connection* sqlConn;
public:
bool Init();
};
bool Server::Init()
{
sqlDriver = get_driver_instance();
return true;
}
I know there are a bunch of topics on this but nothing I've tried has solved it. I haven't written all the things I've tried down as there are a bunch of things.
解决方案
I had the same problem and ended up solving it by switching to "Release" instead of "Debug".
Other related problems are solved by this small change. (See Connection Crash in mysql C++ )
I understand that you solved this using Qt library, but I guess this can help for other people that got stuck in the same place.
Edit:
I've been doing some research on the mysql site (http://dev.mysql.com/downloads/connector/cpp/) and it clearly states that:
One problem that can occur is when the tools you use to build your application are not compatible with the tools used to build the binary versions of MySQL Connector/C++. Ideally, you need to build your application with the same tools that were used to build the MySQL Connector/C++ binaries.
The solution I've found so far is to download the library in source format (not binary) and compile it with the settings I need.