MySQL "libs & include" module not found
I'm reading the documentation about how to use MySQL in Qt5 applications:
You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module.
But I cannot find this module in the MySQL installation! I downloaded the last version of the community release.
Am I missing something obvious?
You need to link against the libmysql.dll by having INCLUDEPATH set to include the mysql.h directory and LIBS set to include (-L) the lib-path and the library to link against (-l).
cd %QTDIR%/src/qtbase/src/plugins/sqldrivers/mysql qmake "CONFIG+=release" "INCLUDEPATH+=C:/temp/mysqlconnector/include" "LIBS+=-LC:/temp/mysqlconnector/lib" "LIBS+=-llibmysql" mysql.pro (n|mingw32-)make (n|mingw32-)make install
Install the apropriate header files for your linux destribution.
Thank you! With your hints I successfully compiled the plugins, which are place into:
Now I'm facing the common issue of "QMYSQL driver not loaded but available". I read tons of thread about this but I'm asking some clarification about.
I checked the db server is up (from MySQL Workbench I can connect)
in the pro file of my test app I set:
QT += sql
- this is my connection code:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setPort(3306); db.setDatabaseName("test"); db.setUserName("root"); db.setPassword(""); qDebug() << db.open();
in the documentation I cannot find the page where are described the requisites, like which libs to link with, etc...
the error is present only in debug mode1 In release it connect successfully! Anyway I have also qsqlmysqld.dll in the plugins folder.