使用mysql+;构建应用程序时未找到mysql_version.h+; 我想用C++在MySQL数据库中连接MySQL +库(包装器)在Linux(Ubuntu 12.04)。我通过xampp for linux安装了mysql,但也用sudo-apt-get-istall-mysql服务器进行了尝试。我用sudo apt get install libmysqlclient15 dev获得了mysql++库
include语句使用mysql+;构建应用程序时未找到mysql_version.h+; 我想用C++在MySQL数据库中连接MySQL +库(包装器)在Linux(Ubuntu 12.04)。我通过xampp for linux安装了mysql,但也用sudo-apt-get-istall-mysql服务器进行了尝试。我用sudo apt get install libmysqlclient15 dev获得了mysql++库,c++,mysql,mysql++,C++,Mysql,Mysql++,include语句include没有给出任何警告,但当我尝试构建应用程序时,这是编译错误: 在/usr/include/mysql++/connection.h:38:0中包含的文件中, 从/usr/include/mysql++/mysql++.h:56, from/home/bert/Documents/QtProjecten/FGBG/modules/server/mysqldb.h:6, from/home/bert/Documents/QtProjecten/FGBG/modules/
include
没有给出任何警告,但当我尝试构建应用程序时,这是编译错误:
在/usr/include/mysql++/connection.h:38:0中包含的文件中,
从/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:致命错误:mysql\u version.h:没有这样的文件或目录
编译已终止。
实际上,在/usr/include/mysql++
目录中没有mysql\u version.h
。有人知道这是什么意思吗?我几乎找不到关于这个问题的任何文档,甚至试图将mysql\u version.h
-文件从/usr/include/mysql
复制到/usr/include/mysql++
编辑:
- 我的文件系统中有两个mysql++dir:
和/usr/local/include/mysql++
。这可能是个问题吗/usr/include/mysql++
- 我将
更改为#include
,但不起作用 - 当我更改我的Cmakelist中的GXX标志(
或-DMYSQLPP\u MYSQL\u HEADERS\u-burned
)时,它不再识别-I/usr/include/MYSQL
名称空间mysqlpp
#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
\ifndef MYSQLDB\u H
#定义MYSQLDB_H
#包括
类MySQLDB{
公众:
MySQLDB();
~MySQLDB();
bool-open(std::string-dbname、std::string-hostname、std::string-username、std::string-password);
mysqlpp::StoreQueryResult查询(std::stringsql);
bool-close();
私人:
mysqlpp::连接连接;
};
#恩迪夫
如果您构建自己的软件包,从系统(mysql++)中卸载所有相关的开发软件包可能会有所帮助。mysql\u版本。h是mysql软件包的一部分,而不是mysqlpp软件包。只需include/usr/include/mysql或usr/local/include/mysql[取决于您在IDE中安装mysql开发文件的位置]。简易解决方案(:使用-DMYSQLPP\u MYSQL\u HEADERS\u burned
标志编译,或直接包含MYSQL目录。即,尝试以下操作之一:
g++ test.cpp -o test -DMYSQLPP_MYSQL_HEADERS_BURIED
g++ test.cpp -o test -I/usr/include/mysql/
这两种方法对我都有效
更多信息可以在中找到。检查是否可以使用
dpkg -L libmysql++-dev
如果是,即如果您有libmysqlpp.a,请使用-lmysqlpp链接它,如下所示:
g++ sm_cpp.cpp -o test -I/usr/include/mysql++ -I/usr/include/mysql -lmysqlpp
它会起作用。链接器搜索库的标准目录列表,实际上是一个名为liblibrary.a的文件。然后链接器使用此文件,就好像它是按名称精确指定的一样。您好,请查看我的编辑。您对此有什么建议吗?谢谢