0

I am trying to run sample program for mysql c++ connect. each time getting error. Here are various way I tried from various solutions with no luck.

Any help will be highly appreciated!

g++ -o a temp.cpp -lmysqlcppconn  // error : many error like /usr/lib/gcc/i686-linux-gnu/4.7/../../../../lib/libmysqlcppconn.so: undefined reference to `mysql_next_result@libmysqlclient_18'


 g++ -o test -Iinclude -Llib -L/usr/lib64/mysql -lmysqlclient temp.cpp // error: /usr/bin/ld: cannot find -lmysqlclient


    g++ -Wall -o firsttry_prog -I/usr/include/mysqlcppconn -L/usr/lib/mysqlcppconn temp.cpp -lmysqlcppconn  // ERRor : kind of dozens error : /usr/lib/gcc/i686-linux-gnu/4.7/../../../../lib/libmysqlcppconn.so: undefined reference to `mysql_stmt_field_count@libmysqlclient_18'


    sudo g++ -Wall -I/usr/include/cppconn -o testapp temp.cpp -L/usr/lib -lmysqlcppconn  //gives dozens of error

1 Answer 1

1

Looks like you don't have the mysqlclient lib installed.

Try this if you made sure you installed it:

g++ -o temp.o -c `mysql_config --cflags` temp.cpp
g++ -o temp temp.o -lmysqlcppconn `mysql_config --libs`

see MySQL - Building C API Client Programs

Sign up to request clarification or add additional context in comments.

8 Comments

I installed it again sudo apt-get install mysql-client but no change!
Simple running it like : g++ -o a temp.cpp -lmysqlcppconn should not work?
how to find default installation location for mysql? m
Thanks, some progress! First line executes successfully. 2nd line gives again temp.o: In function main': /home/technoworld/Desktop/temp.cpp:23: undefined reference to get_driver_instance' collect2: error: ld returned 1 exit status error!
Try with g++ -o temp temp.o -lmysqlcppconn mysql_config --libs`
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.