gpt4 book ai didi

c++ - 为什么 `sqlpp-mysql` 没有正确链接?

转载 作者:行者123 更新时间:2023-11-29 20:11:56 25 4
gpt4 key购买 nike

我正在尝试使用 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 没有正确链接。有人可以给我一些指示,如何解决这个问题吗?

P.S:我已经构建了要求。

我像这样构建了sqlpp11sqlpp11-connector-mysql

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

最佳答案

我需要正确链接库。

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

关于c++ - 为什么 `sqlpp-mysql` 没有正确链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40037211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com