MySQL Forums
Forum List  »  Connector/C++

Re: Error: undefined reference to get_driver_instance
Posted by: nate givon
Date: February 09, 2010 05:51AM

I haven't been able to fix the problem either. I'm on windows 7 and installed the mysql-c++ connector via 64bit .msi. Building the following code with codeblocks mingw compiler:
#include <stdio.h>
#include <stdlib.h>
#include "mysql_connection.h"
#include "mysql_driver.h"
#include <cppconn\driver.h>
#include <cppconn\exception.h>
#include <cppconn\resultset.h>
#include <cppconn\statement.h>
#include <cppconn\prepared_statement.h>

using namespace std;
using namespace sql::mysql;
using namespace sql;

sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
sql::PreparedStatement *pstmt;

int main( int argc, char* argv[] )
{
driver = get_driver_instance();

printf("hello world\n");
return 0;
}

The compiler's build log:

mingw32-g++.exe -I"C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include" -I"C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt" -IC:\Users\nate\Desktop\auto -IC:\Users\nate\Desktop\auto\cppconn -IC:\Users\nate\Desktop\auto\Release -IC:\Users\nate\Desktop\auto -c C:\Users\nate\Desktop\auto\test.cpp -o C:\Users\nate\Desktop\auto\test.o
mingw32-g++.exe -L"C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include" -L"C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt" -LC:\Users\nate\Desktop\auto -LC:\Users\nate\Desktop\auto\cppconn -LC:\Users\nate\Desktop\auto\Release -o C:\Users\nate\Desktop\auto\test.exe C:\Users\nate\Desktop\auto\test.o "C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib" "C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn-static.lib"
C:\Users\nate\Desktop\auto\test.o:test.cpp:(.text+0x129): undefined reference to `__imp__get_driver_instance'
collect2: ld returned 1 exit status

I know the issue is supposed to be with the linking of the mysql library "mysqlcppconn.lib", and it looks like the compiler is linking to it like I told codeblocks to do...can anybody see whats causing this problem?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.