I want to connect to my MySQL database with c++ with the mysql++ library (wrapper) in linux (ubuntu 12.04). I installed mysql via the xampp for linux, but also tried it with sudo apt-get istall mysql-server
. I got the mysql++ lib with sudo apt-get install libmysqlclient15-dev
.
The include statement include <mysql++/mysql++.h>
gave no warning, but when I'm trying to build my application, this is the compilation error:
In file included from /usr/include/mysql++/connection.h:38:0,
from /usr/include/mysql++/mysql++.h:56,
from /home/bert/Documents/QtProjecten/FGBG/modules/server/mysqldb.h:6,
from /home/bert/Documents/QtProjecten/FGBG/modules/server/mysqldb.cpp:1:
/usr/include/mysql++/common.h:131:28: fatal error: mysql_version.h: No such file or directory
compilation terminated.
Indeed there is no mysql_version.h
in the /usr/include/mysql++
directory. Does anybody have a clue what this means? I almost couldn't find any documentation on this matter and I even tried to copy the mysql_version.h
-file from /usr/include/mysql
to /usr/include/mysql++
.
Edit:
- I have two mysql++ dirs in my file system:
/usr/local/include/mysql++
and/usr/include/mysql++
. Could this be a problem? - I changed
#include <mysql++/mysql++.h>
to</usr/include/mysql++/mysql++.h>
, didn't work. - When I change the GXX flags (
-DMYSQLPP_MYSQL_HEADERS_BURIED
or-I/usr/include/mysql
) in my Cmakelist, it doesn't recognize themysqlpp
namespace anymore.
Here is the code of my header file:
#ifndef MYSQLDB_H
#define MYSQLDB_H
#include <mysql++/mysql++.h>
class MySQLDB{
public:
MySQLDB();
~MySQLDB();
bool open(std::string dbname, std::string hostname, std::string username, std::string password);
mysqlpp::StoreQueryResult query(std::string sql);
bool close();
private:
mysqlpp::Connection conn;
};
#endif