我发现这个论坛上有关同一个错误的一些主题,但我没有找到解决方案。C++/Mysql连接器:未定义的参考`get_driver_instance'
我想让工作C++ & Ubuntu 11.04上的Mysql连接器。 我的错误的是(以下MySQL官方教程后)
/tmp/ccDmH4pd.o: In function `main':
mysql.cpp:(.text+0xb): undefined reference to `get_driver_instance'
collect2: ld returned 1 exit status
这里是我的代码:
int main(){
sql::Driver* driver; // Create a pointer to a MySQL driver object
sql::Connection* dbConn; // Create a pointer to a database connection object
sql::Statement* stmt; // Create a pointer to a Statement object to hold our SQL commands
sql::ResultSet* res; // Create a pointer to a ResultSet object to hold the results of any queries we run
driver = get_driver_instance();
dbConn = driver->connect(server, username, password);
delete dbConn;
return 0;
}
这里是我包括:事先大家
#include "mysql_driver.h"
#include "mysql_connection.h"
// Include the Connector/C++ headers
#include "cppconn/driver.h"
#include "cppconn/exception.h"
#include "cppconn/resultset.h"
#include "cppconn/statement.h"
感谢
Touki
你是如何编译/链接? – Mat