我正在尝试使用sqlpp-connector-mysql建立数据库连接。在我尝试运行SampleTest.cpp
时构建此项目后,会产生错误
$ g++ -std=c++1y -lsqlpp-mysql SampleTest.cpp
SampleTest.cpp:(.text+0x12f): undefined reference to `sqlpp::mysql::connection::connection(std::shared_ptr<sqlpp::mysql::connection_config> const&)'
SampleTest.cpp:(.text+0x13e): undefined reference to `sqlpp::mysql::connection::~connection()'
SampleTest.cpp:(.text+0x157): undefined reference to `sqlpp::mysql::connection::connection(std::shared_ptr<sqlpp::mysql::connection_config> const&)'
SampleTest.cpp:(.text+0x19d): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
SampleTest.cpp:(.text+0x201): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
SampleTest.cpp:(.text+0x265): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
SampleTest.cpp:(.text+0x2c9): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
我认为,sqlpp-mysql
没有正确链接。有人可以给我一些指针,如何解决这个问题?
我像这样构建了sqlpp11
和sqlpp11-connector-mysql
$ cd project_dir
$ cmake CmakeList.txt
$ sudo make install
答案 0 :(得分:0)
我需要正确链接库。
g++ -std=c++11 tests/SampleTest.cpp -I ../../sqlpp11/include -I . -I ../../date -lsqlpp-mysql -lmysqlclient