문제


as many others I have got the problem to compile a program including mysqlpp.
mysqlpp seems to be installed correctly, the library paths are set correctly in /etc/ld.so.conf also and are known (so I think):

$ 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

But something seems to be wrong, the compiler doesn't find the library of mysqlpp.
Linking-Compiler command:

 /usr/bin/c++ -lm -L/usr/lib -L/usr/lib/x86_64-linux-gnu/ -lmysqlclient -lmysqlpp -o myprogram  myprogram.o

Error-Message that the mysqlpp references are missing (beside from many other missing references):

/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

I am at my wit's end. Perhaps somebody of you can help me. Thanks!!

도움이 되었습니까?

해결책

The linker looks for dependencies in reverse order, so you need to put the libraries after the object (or source) files on the command line.

$ c++ myprogram.o -o myprogram -lm -L/usr/lib -L/usr/lib/x86_64-linux-gnu/ -lmysqlclient -lmysqlpp
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top