This evening I tried to connect to MySQL server from my C++ application. So, some notes about this task:
- If I use 64 bit versions of MySQL Server, MySQL/C++ Connector and Windows 7 it fails to load. I got a linker error saying that get_driver_instance() is unresolved function.
- After some googling I found out that this function works only with dynamically linked library.
- But it also failed to load.
- So, as a result I installed 32 bit versions of MySQL and MySQL/C++ Connector.
- But it also failed to connect to server. The problem was that after calling driver->connect() I got an exception.
- The solution was to include libmysql.dll, libmysqld.dll and mysqlcppconn.dll into my project. In linker properties I added a path to: "C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib\";"C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.0\lib\debug". Libraries used: mysqlcppconn.lib libmysqld.lib.
Well, that's it. Now it works :) But it works on 32 bits, not on 64 bits :/
Some useful links: