Sign in to follow this  
ajm113

Mysql Connector Doesn't Work (VS2008 C++)

Recommended Posts

Hello I'm getting this linking error on this line using mysql's connector C++ API.
//Initalize mysql connector C++
		driver = sql::mysql::get_mysql_driver_instance();

Error: LNK2001: unresolved external symbol "__declspec(dllimport) class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_mysql_driver_instance(void)" (__imp_?get_mysql_driver_instance@mysql@sql@@YAPAVMySQL_Driver@12@XZ) How my headers are
//...
#include <tchar.h>
#include <string.h>
#include <vector>
#include <stdexcept>


/* MySQL Connector/C++ specific headers */
#include <mysql_connection.h>
#include <mysql_driver.h>

#include <cppconn/driver.h>
#include <cppconn/connection.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/resultset.h>
#include <cppconn/metadata.h>
#include <cppconn/resultset_metadata.h>
#include <cppconn/exception.h>
#include <cppconn/warning.h>




And yes I have "mysqlcppconn.lib" added and my project is in release mode. I'm I forgetting something to do with the API? I downloaded the API from the installer from Mysql directly if that helps a little. Thanks, Andrew

Share this post


Link to post
Share on other sites
Hello,

I recently had the same problem. I use an 64bits OS, and I used the 64bits version of MySQL Server in combination with the 32 bits connector.

The solution for me was to download the archived version of both the connector and the community server, unzip them somewhere, let MSVS2008 know where they were and it instantly worked.

Edit: I forgot to mention that you also need to include the "libmysql.lib" and "mysqlclient.lib" from the server edition.

Maybe that will fix your problem?

Regards,

Forsith

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this