Reputation: 141
Today, I want to ask you a question about building drivers. I have my little QT Database like this:
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. So, I typed this at my 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). 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.
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; dirs in system as a "PATH" variable.
Thank you in advance!
Upvotes: 2
Views: 1114
Reputation: 5557
As you're running on Windows, you have to install the MySQL C client (that's where the mysql.h
file is coming from).
Upvotes: 1