[英]SOCI Undefined Reference Error During Compilation
I'm trying to get soci working, and am basing my code on their documentation here . 我正在努力使soci正常工作,并将我的代码建立在这里的文档基础上。 I'm getting an error that I can't decipher.
我遇到了我无法解读的错误。
My code: 我的代码:
// relevant imports
using namespace soci;
using namespace std;
int main(int argc, char** argv) {
string dbName = "mysql";
string options = "dbname=db user=root password=abc";
try {
session sql(dbName, options); // this is line 22
} catch (exception e) {
printf("%s", e.what());
}
printf("working");
return 0;
}
The error: 错误:
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/kevin/Dropbox/bamboo/main.cpp:22: undefined reference to
`soci::session::session(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/kevin/Dropbox/bamboo/main.cpp:22: undefined reference to `soci::session::~session()'
You need to link against the soci library and the appropriate backend. 您需要链接到社会图书馆和适当的后端。 Add "-lsoci" to your linker command line.
在您的链接器命令行中添加“ -lsoci”。
Update: 更新:
Based on comments, you need to add: 根据评论,您需要添加:
-L/usr/local/lib -lsoci_core -lsoci_mysql
to your linker command line. 到您的链接器命令行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.