views:

148

answers:

1

I'm getting "undefined reference to 'get_driver_instance'" when building even the most simple example from: http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-examples-complete-example-1.html. It builds and runs fine on my local machine but it won’t build on the server – seems like linking mysql library issue.
This is my build cmd:
g++ -o test -Iinclude -Llib -L/usr/lib64/mysql main.cpp

I can’t run the local built binary on the server as it was built using dynamic 'libmysqlclient.so'. I also tried to install the static libmysqlclient.a on my local machine but I can’t find ‘libmysqlclient.a’ in my /usr/lib/mysql dir. I assume Only way to run it on the server is if I can either build it statically on my local machine or I can compile and build it directly on the server. I tried ‘sudo yum install mysql-devel’ but I only see libmysqlclient.so -- can’t find ‘libmysqlclient.a’. Is there a way to install a static mysqlclient on my local linux or is my build cmd wrong? How can I build source code on the server?

A: 

try to add '-lmysqlclient' to the command, i.e.: g++ -o test -Iinclude -Llib -L/usr/lib64/mysql -lmysqlclient main.cpp

shuvalov
hi shuvalov, tried but no success. seems like i'm having a linking issue with mysql-connector/c++ header files. This is how my folder structured: /include --> contains /cppconn and mysql_driver.h and mysql_connection.h. /lib --> contains downloaded /lib dir of mysqlc++-connector. /usr/lib64/mysql --> contains libmysqlclient
Azeem Michael