Saturday, March 8, 2008

Install mysql++ for C++ connection to mysql database

1. Install mysql

2. Install mysqlpp-3.0 from source
http://tangentsoft.net/mysql++/releases/mysql++-3.0.0.tar.gz.
Don't use apt-get to install libmysqlpp-dev if you are using old version of ubuntu. It would give you outdated version of mysql++.
Generally it would be install in /usr/local/include and the libs would appear in /usr/lib/ or /usr/local/lib.

3. include mysql++.h in your program.

4. in your make file, put the following flags when you compile and build:
//include the header files
-I/usr/local/include/mysql++ -I/usr/include/mysql
//load the libraries. otherwise you are gonna get undefined reference error during linking stage.
-L/usr/local/lib -lmysqlpp (-lmysqlclient)
The path might differ from different linux distributions. Look for the lib named libmysqlpp.so* and libmysqlclient.so*.

5. remember to put the library path in /etc/ld.so.conf, and sudo ldconfig

No comments: