2016-10-14 158 views
0

我正在嘗試使用sqlpp-connector-mysql建立數據庫連接。當我試圖運行建設這個項目後SampleTest.cpp它產生錯誤說爲什麼`sqlpp-mysql`不適合鏈接?

$ 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未正確連接。有人可以給我一些指針,如何解決這個問題?

P.S:我已經建立了要求。

我建立了兩個sqlpp11sqlpp11-connector-mysql這樣

$ cd project_dir 
$ cmake CmakeList.txt 
$ sudo make install 

回答

0

我需要的庫正確鏈接。

g++ -std=c++11 tests/SampleTest.cpp -I ../../sqlpp11/include -I . -I ../../date -lsqlpp-mysql -lmysqlclient