简体   繁体   English

使用 MYSQL 服务器 (mingw32-make) 为 QT 构建驱动程序时出错

[英]Error building drivers for QT using MYSQL server (mingw32-make)

Today, I want to ask you a question about building drivers.今天,我想问你一个关于构建驱动程序的问题。 I have my little QT Database like this:我有这样的小 QT 数据库:

mainDB = QSqlDatabase::addDatabase("QMYSQL");
mainDB.setHostName("127.0.0.1");
mainDB.setPort(3306);
mainDB.setDatabaseName("Database_Name");
mainDB.setUserName("root"); //create editors account later
mainDB.setPassword("Password"); //so on :)
if(mainDB.open())
    qDebug() << "mainDB is open";
else
    qDebug() << "mainDB error";

However, then I tried to compile this, I received an error:但是,然后我尝试编译它,我收到一个错误:

QSqlDatabase: QMYSQL driver not loaded             
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

I googled this thing a little bit, and realised, what I haven't build a driver for QT, using MySQL.我在谷歌上搜索了一下这个东西,并意识到我还没有使用 MySQL 为 QT 构建驱动程序。 So, I typed this at my cmd:所以,我在我的 cmd 中输入了这个:

C:\Qt\5.6\Src\qtbase\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH += C:\Program Files\MySQL\MySQL Server 5.7\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 5.7\lib\libmysql.lib" mysql.pro

(in includepath I used path to all includes in MySQL server (like, a hundred of h. files), and in LIBS I used path to my libmysql file). (在包含路径中,我使用了 MySQL 服务器中所有包含的路径(例如,一百个 h. 文件),而在 LIBS 中,我使用了 libmysql 文件的路径)。 It compiled good, and I typed它编译得很好,我输入了

mingw32-make

to finish my build.完成我的构建。 However it catches an error:但是它捕获了一个错误:

    In file included from main.cpp:36:0:
    ../../../sql/drivers/mysql/qsql_mysql_p.h:55:19: fatal error: mysql.h: No
   such file or directory
 #include <mysql.h>
                   ^
compilation terminated.
Makefile.Release:466: recipe for target '.obj/release/main.o' failed
mingw32-make[1]: *** [.obj/release/main.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/5.6/Src/qtbase/src/plugins/sqldrivers/
mysql'
makefile:38: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2

and, as a result, my C:\\Qt\\5.6\\Src\\qtbase\\plugins\\sqldrivers is empty.结果,我的 C:\\Qt\\5.6\\Src\\qtbase\\plugins\\sqldrivers 是空的。

So, I want to know, how to fix it?所以,我想知道,如何解决它?

And, yeah, I did include C:\\Qt\\5.6\\mingw49_32\\bin;C:\\Qt\\Tools\\mingw492_32\\bin;而且,是的,我确实包含了 C:\\Qt\\5.6\\mingw49_32\\bin;C:\\Qt\\Tools\\mingw492_32\\bin; dirs in system as a "PATH" variable. dirs 在系统中作为“PATH”变量。

Thank you in advance!先感谢您!

当您在 Windows 上运行时,您必须安装MySQL C 客户端(这是mysql.h文件的来源)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM