Install MySQL connector/C++ on Ubuntu 11.04

Here is what I did to install MySQL and connector/C++.
First install MySQL Server.

Then download MySQL connector/C++ from here.
I used the binary file.



Extract the file and rename the folder, say, mysql.
Copy mysql/include/* to /usr/include/
Copy mysql/lib/* to /usr/lib/

When I build a cpp file using the following command:
    $g++ -Wall test.cpp -o t

the following error was issued:
    sql01.cpp:(.text+0x44): undefined reference to `get_driver_instance'
collect2: ld returned 1 exit status

After google for a while, I found I need to link libmysqlcppconn.so in the command like this:

    $g++ -Wall test.cpp -lmysqlcppconn -o t
But this time, instead of an error, a warning was issued:

    warning: libstdc++.so.5, needed by /usr/lib/libmysqlcppconn.so, may conflict with libstdc++.so.6

Finally, I add /usr/lib/libstdc++.so.5 into the command and solved this problem.

    $g++ -Wall test.cpp -lmysqlcppconn /usr/lib/libstdc++.so.5 -o t

8 comments:

vad said...

You are AWESOME! I've been searching for this solution for 2 weeks, literally 24/7. So much so, I was losing lots of sleep and my personality was changed :) Right now it's 2:35a and I've been searching all day today since I woke up. I don't know if I am delirious from mental fatigue from excessive searching, but I feel like crying from shear unbridal happiness. Your post literally changed my life. Thank you very, very much.

Anonymous said...

thumbs up!! Thanks man

Anonymous said...

WOW јust what I ωaѕ seaгching fоr.
Сamе here bу ѕearсhing for vaгiates

Have а loοk at my pagе ... RPMPoker Promotions

Anonymous said...

Hеllo to every , foг the reаsοn thаt ӏ
аm in fact keen of reading this blog's post to be updated daily. It carries nice information.

my website; Red Kings Poker Bonus

Anonymous said...

We stumbled oѵer here cοming fгom а diffeгent web раge and thought I might check things out.
I liκe what I see so now i'm following you. Look forward to going over your web page for a second time.

Take a look at my weblog; MintedPoker Bonus

Anonymous said...

Thank you. It worked. Many webpages were suggesting various things, but none of them worked. Your post relieved me of the frustration of getting mysql to connect to c++.

Anonymous said...

I was able to fіnԁ good adνice fгom youг аrticles.


Feel free tо surf to mу blog рost diamondlinks review

Anonymous said...

I аbsolutely love yοur sіte.
. Very nісe cοlorѕ & theme. Did you build
thiѕ wеb site yourself? Please reply bаck as I'm hoping to create my own personal site and would like to find out where you got this from or what the theme is named. Thank you!

Look into my homepage Americas Cardroom Poker Bonus ()