2
votes

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 <cppconn/driver.h>
 #include <cppconn/exception.h>
 #include <cppconn/resultset.h>
 #include <cppconn/statement.h>

 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.

1
Try with sqlDriver = sql::mysql::get_driver_instance();Jigsore
I tried that already. You forgot to mention that you also have to #include "mysql_driver.h" when doing that and that it doesn't return a Driver* object but a MySQL_Driver* object. Anyway after doing all that I still get the linker error "unresolved external symbol "class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_driver_instance(void)" (?get_driver_instance@mysql@sql@@YAPAVMySQL_Driver@12@XZ) referenced in function"user441521
Nevermind I guess. I just used Qt's sql modules and it works.user441521

1 Answers

0
votes

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.