문제

I am trying to compile a program written in c++ with the following command line:

g++ test.cpp pugixml-1.0/src/pugixml.cpp -lcurl -lmysqlclient -lmysqlcppconn-static -lboost_thread

This goes all well on a Debian 32 Bit machine, but fails in Ubuntu 64 Bit and I have no clue why. I have installed all required packages for the usage of mysql. The error message looks like the following:

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmysqlcppconn-static.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::thread_init()':
(.text+0x1): undefined reference to `mysql_thread_init'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmysqlcppconn-static.a(mysql_client_api.cpp.o): In function `sql::mysql::NativeAPI::LibmysqlStaticProxy::thread_end()':
(.text+0x11): undefined reference to `mysql_thread_end'
etc. ...
collect2: ld returned 1 exit status

The message is quite long and all lines look quite similar with changing references ;)

도움이 되었습니까?

해결책

Try to inverse the order of -lmysqlclient -lmysqlcppconn-static in your linker call.

If object A needs symbols from object B, A must be in front of B in the linker command line.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top