MySQL Connector / C ++ library related to ERROR issue

PROBLEM:

Ok, I tried following the sample code on the MySQL Forge Wiki and some other websites that offer a tutorial on how to get a simple database connection, but for some reason my project always fails on a bind error and I can't figure out why and how to fix it yourself (I'm still researching). PLEASE, HELP! I have included the path directory required for the header files in the project properties AND provided the path directory for the lib files that are used in MySQL Connector / C ++. The code I am using is below in case someone can give me some useful advice / comment on how to fix it. I think it has to do with linking to lib files (due to linking error), but I don't know how to fix it. Has anyone else had problems like this?

http://forge.mysql.com/wiki/Connector_C++ http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html#createdb

CODE:

int main() {
    // do something
    sql::mysql::MySQL_Driver *driver;
    sql::Connection *con;
    sql::Statement *stmt;
    sql::ResultSet *res;
    sql::PreparedStatement *pstmt;

    cout << "Starting Driver Instance" << endl;
    driver = sql::mysql::MySQL_Driver::get_mysql_driver_instance();

    return 0;
}

      

MISTAKE:

1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\users\josh bradley\documents\visual studio 2008\projects\test\test\main.cpp(28) : error C2039: 'get_mysql_driver_instance' : is not a member of 'sql::mysql::MySQL_Driver'
1>        c:\program files\mysql\mysql connector c++ 1.0.5\include\mysql_driver.h(25) : see declaration of 'sql::mysql::MySQL_Driver'
1>c:\users\josh bradley\documents\visual studio 2008\projects\test\test\main.cpp(28) : error C3861: 'get_mysql_driver_instance': identifier not found
1>Build log was saved at "file://c:\Users\Josh Bradley\Documents\Visual Studio 2008\Projects\test\test\Debug\BuildLog.htm"
1>test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

      

UPDATE:

I just wanted to let everyone know that I finally figured out how to fix my problem. For those with a similar problem, go to http://blog.ulf-wendel.de/?p=215#hello and read the instructions on how to dynamically connect to mysqlcppconn.lib. My problem was setting up a real environment so that it would link to the library correctly and this tutorial helped a lot!

+2


source to share


3 answers


You must first change your code:

driver = sql::mysql::get_mysql_driver_instance();

      

And next you need to link your code to mysqlclient.lib Add to your project the correct path to your lib mysqlclient.lib :



Properties->Linker->General-> Additionnal Libraries

      

Add the path to your lib here.

+3


source


A quick Google search suggests your string should read:



driver = sql::mysql::get_mysql_driver_instance();

      

+1


source


The error is a compiler error. It complains that it cannot find get_mysql_driver_instance () in the specified namespace.

Try double clicking the line:

1>        c:\program files\mysql\mysql connector c++ 1.0.5\include\mysql_driver.h(25) : see declaration of 'sql::mysql::MySQL_Driver'

      

It will show you the header file and you can search there to make sure the feature is present.

0


source







All Articles