我正在尝试在Ubuntu 16.04中为C ++ MySQL连接器库重现example。已安装libmysqlcppconn-dev
。这是我的计划:
#include <mysql_connection.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
int main(void)
{
sql::mysql::MySQL_Driver *driver;
sql::mysql::MySQL_Connection* con;
delete party;
driver = sql::mysql::get_mysql_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "user", "password");
return 0;
}
我正在尝试编译它:
g++ -I/usr/include -I/usr/include/cppconn probe.cpp -lmysqlcppconn
编译会出错:
probe.cpp: In function ‘int main()’:
probe.cpp:31:5: error: ‘MySQL_Driver’ is not a member of ‘sql::mysql’
sql::mysql::MySQL_Driver *driver;
^
probe.cpp:31:31: error: ‘driver’ was not declared in this scope
sql::mysql::MySQL_Driver *driver;
^
probe.cpp:34:14: error: ‘get_mysql_driver_instance’ is not a member of ‘sql::mysql’
driver = sql::mysql::get_mysql_driver_instance();
YouCompleteMe提供sql::mysql::*
但不包含MySQL_Driver
的各种成员。
这里有什么问题?也许我应该安装一些头文件,或使用其他编译器选项?对不起,如果我的问题很简单或愚蠢。