Reputation: 880
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 ;)
Upvotes: 3
Views: 1952
Reputation: 206669
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.
Upvotes: 3