和其他许多人一样,我在编译包括 mysqlpp 的程序时遇到了问题。
mysqlpp 似乎安装正确,库路径也在 /etc/ld.so.conf 中正确设置并且是已知的(所以我认为):
$ sudo ldconfig -p | grep mysql
libmysqlpp.so.3 (libc6,x86-64) => /usr/local/lib/libmysqlpp.so.3
libmysqlpp.so (libc6,x86-64) => /usr/local/lib/libmysqlpp.so
libmysqlclient.so.18 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
libmysqlclient.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libmysqlclient.so
但是好像有问题,编译器没有找到mysqlpp的库。
链接编译器命令:
/usr/bin/c++ -lm -L/usr/lib -L/usr/lib/x86_64-linux-gnu/ -lmysqlclient -lmysqlpp -o myprogram myprogram.o
缺少 mysqlpp 引用的错误消息(除了许多其他缺少的引用):
/usr/local/include/mysql++/row.h:328: undefined reference to `mysqlpp::Row::at(unsigned long) const'
myprogram.o: In function `mysqlpp::StoreQueryResult::operator=(mysqlpp::StoreQueryResult const&)':
/usr/local/include/mysql++/result.h:252: undefined reference to `mysqlpp::StoreQueryResult::copy(mysqlpp::StoreQueryResult const&)'
myprogram.o: In function `long mysqlpp::String::do_conv<long>(char const*) const':
/usr/local/include/mysql++/mystring.h:615: undefined reference to `mysqlpp::String::length() const'
/usr/local/include/mysql++/mystring.h:615: undefined reference to `mysqlpp::String::data() const'
collect2: ld returned 1 exit status
我已经黔驴技穷了。也许你们中的某个人可以帮助我。谢谢!!