我的系统是Kubntu 15.10
,昨天我Qt 5.5.1 Opensource
通过升级了 Qt 版本MaintenanceTool
。今天我通过 安装了 mysql 开发包sudo apt-get install libmysqlclient-dev
。现在,从Qt 文档,我尝试使用 编译mysql
插件:
cd /opt/QtOpenSource55/5.5/Src/qtbase/src/plugins/sqldrivers/mysql
然后使用 运行qmake
。
/opt/QtOpenSource55/5.5/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro && make all && make install
编译过程以以下错误结束:
g++ -c -pipe -I/usr/include/mysql -O2 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x -fno-exceptions -Wall -W -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I/usr/local/include -I/opt/QtOpenSource55/5.5/Src/qtbase/include/QtCore/5.5.0 -I/opt/QtOpenSource55/5.5/Src/qtbase/include/QtCore/5.5.0/QtCore -I/opt/QtOpenSource55/5.5/Src/qtbase/include/QtSql/5.5.0 -I/opt/QtOpenSource55/5.5/Src/qtbase/include/QtSql/5.5.0/QtSql -I../../../../include -I../../../../include/QtSql -I../../../../include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/qsql_mysql.o ../../../sql/drivers/mysql/qsql_mysql.cpp
../../../sql/drivers/mysql/qsql_mysql.cpp:36:40: fatal error: QtSql/private/qsqldriver_p.h: No such file or directory
#include <QtSql/private/qsqldriver_p.h>
^
compilation terminated.
Makefile:2003: recipe for target '.obj/qsql_mysql.o' failed
make: *** [.obj/qsql_mysql.o] Error 1
libmysqlclient-dev
现在,使用命令的软件包信息dpkg -L libmysqlclient-dev|grep qsqldriver_p.h
没有返回任何结果,这意味着有问题的文件根本没有安装。为什么?
答案1
缺少的文件QtSql/private/qsqldriver_p.h
位于包中qtbase5-private-dev
sudo apt-get install qtbase5-private-dev
答案2
在源目录中找到它(类似于qtbase/src/sql/kernel
)并将其复制到包含目录/opt/QtOpenSource55/5.5/gcc_64/include/QtSql/5.5/QtSql/private
。