This post has already been read 2887 times!

The key to use mysql++ on Ubuntu system is to find where the mysql++.h head files and the .so binary files.

First install mysqlclient and mysql++ on Ubuntu:

root# apt-get install libmysqlclient-dev libmysqld-dev libmysql++-dev libmysql++-doc libmysql++3

This will install the mysql head files in /usr/include/mysql, mysql++ head files in /usr/include/mysql, and and in /usr/lib.
These are all the files we need.

Now let us use the mysql++ library.

Save the simple code below as test.cpp


int main(){
mysqlpp::String s(“hello, world”);
std::cout << s << std::endl; return 0; }

And save the makefile as Makefile:

CXX := g++
CXXFLAGS := -I/usr/include/mysql -I/usr/include/mysql++

LDFLAGS := -L/usr/lib -lmysqlpp -lmysqlclient -lnsl -lz -lm

all: test
clean: rm -f $(EXECUTABLE) *.o

Finally, excute

make all

The compile result would be test.

Comments are closed.

Post Navigation