This post has already been read 2776 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 libmysqlpp.so and libmysqlclient.so 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
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
EXECUTABLE := main
clean: rm -f $(EXECUTABLE) *.o
The compile result would be test.