Library 'mysql' is not defined
Solved
General and Desktop
-
Since qmake did not output anything according to your logs you should remove config.cache and start over (already told you above somewhere)
wrote on 5 Dec 2019, 13:59 last edited by hobbyProgrammer 12 May 2019, 14:04@Christian-Ehrlicher alright, I managed to get these files in C:/Qt/Qt5.13.1/5.13.1/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers:
- qsqlmysql.dll
- qsqlmysqld.dll
- qsqlmysql.a
- qsqlmysqld.a
but for some reason I still get this error:
build-testDatabaseDrivers-Desktop_Qt_5_13_1_MinGW_64_bit-Debug\debug\testDatabaseDrivers.exe ... ("QSQLITE", "QODBC", "QODBC3", "QPSQL", "QPSQL7") QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
EDIT:
I copied the .dll files to C:/Qt/Qt<version>/<version>/mingw73_32/plugins/sqldrivers
and now it works -
wrote on 5 Dec 2019, 14:17 last edited by
This worked for me and I used:
- OS: Windows
- Qt version: 5.13.1 and 5.13.2
- Qt creator: 4.10.1
- compiler: mingw73_32
Step by step:
- Download msys & msysgit
- Open the cmd of msys and type these commands (keep in mind that the second and third command do not contain cd. You need to call the .exe files from the mysql path):
- cd <path to libmysql.lib>
- C:/msysgit/mingw/bin/reimp.exe libmysql.lib
- C:/msysgit/mingw/bin/dlltool.exe -k -d libmysql.def -l libmysql.a
- go to the qt cmd called: Qt <version> (<compiler>). Use the one with the mingw32 compiler.
- execute the following commands:
- cd C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers
- qmake sqldrivers.pro
- open mysql.pro and make sure that it looks like this (change the include path and the lib path, but make sure that the include path and the depend path are the same!) and save after you finished editing it:
TARGET = qsqlmysql HEADERS += $$PWD/qsql_mysql_p.h SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp #QMAKE_USE += mysql LIBS += -L'C:/MySQL/lib/' -llibmysql INCLUDEPATH += 'C:/MySQL/include' DEPENDPATH += 'C:/MySQL/include' OTHER_FILES += mysql.json PLUGIN_CLASS_NAME = QMYSQLDriverPlugin include(../qsqldriverbase.pri)
- execute the following commands:
- qmake mysql.pro
- qmake "INCLUDEPATH+=<includepath>" "LIBS+=<libpath>/libmysql.lib" mysql.pro
- mingw32-make
- go to C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers in the file explorer. You should see these four files now:
- qsqlmysql.dll
- qsqlmysqld.dll
- qsqlmysql.a
- qsqlmysqld.a
- copy them and place them into: C:/Qt/Qt<version>/<version>/mingw73_32/plugins/sqldrivers
21/22