I want to connect to a mysql database with C++ in linux. On my local machine I am running Ubuntu, and installed the mysql server and client packages:
sudo apt-get install mysql-server mysql-client
I came across Mysql++ but have some problems when running ./configure from their binary package. The error says:
checking for MySQL library directory... configure: error: Didn't find mysqlclient library in '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql /usr/local/lib64 /usr/local/lib /usr/local/lib/mysql /usr/local/mysql/lib /usr/local/mysql/lib/mysql /usr/mysql/lib/mysql /opt/mysql/lib /opt/mysql/lib/mysql /sw/lib /sw/lib/mysql'
I see where I can use this command to specify the path:
./configure --with-mysql-lib=/...
but I do not know where to point it to. I used whereis mysql but cannot find any mysql directory that contains a lib subdirectory. Where would the mysqlclient libraries be installed?
EDIT:
After doing locate libmysqlclient
I got back
/usr/lib/i386-linux-gnu/libmysqlclient.so.18
/usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18
/usr/lib/i386-linux-gnu/libmysqlclient_r.so.18.0.0
/usr/share/doc/libmysqlclient18
/usr/share/doc/libmysqlclient18/changelog.Debian.gz
/usr/share/doc/libmysqlclient18/copyright
/var/cache/apt/archives/libmysqlclient18_5.5.22-0ubuntu1_i386.deb
/var/lib/dpkg/info/libmysqlclient18:i386.list
/var/lib/dpkg/info/libmysqlclient18:i386.md5sums
/var/lib/dpkg/info/libmysqlclient18:i386.postinst
/var/lib/dpkg/info/libmysqlclient18:i386.postrm
/var/lib/dpkg/info/libmysqlclient18:i386.shlibs
So, I tried ./configure --with-mysql-lib=/usr/lib/i386-linux-gnu
and it seems to complete without any complaining.
Although this solves the problem of getting ./configure to complete, I still have further troubles. When I run make
things go fine until this point:
In file included from ./lib/sql_buffer.h:31:0, from ./lib/sql_buffer.cpp:26: ./lib/refcounted.h:258:2: error: ‘size_t’ does not name a type ./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer()’: ./lib/refcounted.h:89:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’ ./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer(T*)’: ./lib/refcounted.h:100:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’ ./lib/refcounted.h:104:4: error: ‘refs_’ was not declared in this scope ./lib/refcounted.h:104:16: error: expected type-specifier before ‘size_t’ ./lib/refcounted.h:104:16: error: expected ‘;’ before ‘size_t’ ./lib/refcounted.h: In constructor ‘mysqlpp::RefCountedPointer::RefCountedPointer(const ThisType&)’: ./lib/refcounted.h:112:2: error: class ‘mysqlpp::RefCountedPointer’ does not have any field named ‘refs_’ ./lib/refcounted.h:115:8: error: ‘refs_’ was not declared in this scope ./lib/refcounted.h: In destructor ‘mysqlpp::RefCountedPointer::~RefCountedPointer()’: ./lib/refcounted.h:125:7: error: ‘refs_’ was not declared in this scope ./lib/refcounted.h: In member function ‘void mysqlpp::RefCountedPointer::swap(mysqlpp::RefCountedPointer::ThisType&)’: ./lib/refcounted.h:246:13: error: ‘refs_’ was not declared in this scope make: *** [mysqlpp_sql_buffer.o] Error 1
I'm not really familiar with C++, so I'm not sure what the error means exactly. Any help or direction on how to get Mysql++ setup from this point would be much appreciated. Although, I admit that I'm also starting to look for alternative libraries to use.