Bert Dewaele
Bert Dewaele

Reputation: 41

mysql_version.h not found when building application with mysql++

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:

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

Upvotes: 3

Views: 7314

Answers (4)

Yogesh
Yogesh

Reputation: 214

Check if you can link mysqlpp namespace using,

dpkg -L libmysql++-dev

If yes, i.e. if you have libmysqlpp.a, link it using -lmysqlpp as following,

 g++ sm_cpp.cpp -o test -I/usr/include/mysql++ -I/usr/include/mysql -lmysqlpp

It will work. The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name. include <mysql++.h> - No such file or directory

Upvotes: 3

Druckles
Druckles

Reputation: 3782

Compile with the -DMYSQLPP_MYSQL_HEADERS_BURIED flag, or include the mysql directory directly. I.e. try one of the following:

g++ test.cpp -o test -DMYSQLPP_MYSQL_HEADERS_BURIED

g++ test.cpp -o test -I/usr/include/mysql/

Both of these worked for me.

More information can be found in this bug report.

Upvotes: 1

user2597689
user2597689

Reputation: 75

mysql_version.h is part of mysql package, not mysqlpp package. Just include /usr/include/mysql or usr/local/include/mysql [ depends on where you istalled mysql dev files ] into your IDE. Easy solution (:

Upvotes: 1

user2249683
user2249683

Reputation:

If you build your own package it might be helpful to uninstall all related dev package from your system (mysql++).

Upvotes: 0

Related Questions