Library 'mysql' is not defined
-
@hobbyProgrammer said in Library 'mysql' is not defined:
qmake "INCLUDEPATH+=%mysql%\include" "LIBS+=%mysql%\lib\libmysql.lib" -o Makefile mysql.pro
qmake uses
$$(...)
for environment variables, this isn't cmd, do you should try like this:qmake "INCLUDEPATH+=$$(mysql)/\include" "LIBS+=$$(mysql)/lib/libmysql.lib" -o Makefile mysql.pro
@kshegunov Thanks, but I still get the same error.
-
also whenever i open sqldrivers.pro it gives me the same errors:
Project ERROR: Could not find feature sql-mysql.
[Inexact] Project ERROR: Library 'db2' is not defined.
[Inexact] Project ERROR: Library 'oci' is not defined.
[Inexact] Project ERROR: Library 'mysql' is not defined.
[Inexact] Project ERROR: Library 'ibase' is not defined.
[Inexact] Project ERROR: Library 'psql' is not defined.
[Inexact] Project ERROR: Library 'odbc' is not defined.
[Inexact] Project ERROR: Library 'sqlite2' is not defined.
[Inexact] Project ERROR: Library 'tds' is not defined. -
@kshegunov Thanks, but I still get the same error.
Why do you have tilde in your path?
Make sure that you get the correct paths inside the project file (usemessage()
to print them out). Also theqmake
run can be made more verbose if you pass-d
to it (-d -d
for max verbosity).also whenever i open sqldrivers.pro it gives me the same errors:
Well, don't. Not unless you intend to build all the drivers.
-
Why do you have tilde in your path?
Make sure that you get the correct paths inside the project file (usemessage()
to print them out). Also theqmake
run can be made more verbose if you pass-d
to it (-d -d
for max verbosity).also whenever i open sqldrivers.pro it gives me the same errors:
Well, don't. Not unless you intend to build all the drivers.
@kshegunov Hi
Where exactly do I need to add message()?
In the main.cpp? -
Hi,
Looks like you are following the old instructions.
Take a look at the current Qt MySQL driver documentation. The parameters have changed.
-
Hi,
Looks like you are following the old instructions.
Take a look at the current Qt MySQL driver documentation. The parameters have changed.
@SGaist yes, but unfortunately, following the new instructions results in
Project ERROR: Could not find feature sql-mysql -
Based on your first post you are missing two dashes after the
qmake
call. The example from the documentation showsqmake --
and then the additional stuff. Please try that. -
Based on your first post you are missing two dashes after the
qmake
call. The example from the documentation showsqmake --
and then the additional stuff. Please try that.@SGaist so like:
qmake -- MYSQL_INCDIR=:C\MySQL\include "MYSQL_LIBDIR=C:\MySQL\lib" -
@SGaist so like:
qmake -- MYSQL_INCDIR=:C\MySQL\include "MYSQL_LIBDIR=C:\MySQL\lib"This post is deleted! -
This post is deleted!
This post is deleted! -
Based on your first post you are missing two dashes after the
qmake
call. The example from the documentation showsqmake --
and then the additional stuff. Please try that.@SGaist I tried that, but it still won't work. I also do not get the configuration screen where you can see which drivers are installed. Only when I do mingw32-make I see that it only goes to odbc and sqlite
C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=:C\MySQL\include MYSQL_LIBDIR=C:\MySQL\lib C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>mingw32-make cd odbc\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\odbc\odbc.pro ) && mingw32-make -f Makefile mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make -f Makefile.Release all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make -f Makefile.Debug all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' cd sqlite\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\sqlite\sqlite.pro ) && mingw32-make -f Makefile mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make -f Makefile.Release all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make -f Makefile.Debug all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
Also this doesn't seem to work:
C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>mingw32-make sub-mysql mingw32-make: *** No rule to make target 'sub-mysql'. Stop.
-
You still have typos in your paths.
-
@SGaist in the mysql_incdir/mysql_libdir? or anywhere else?
-
@SGaist in the mysql_incdir/mysql_libdir? or anywhere else?
-
@jsulm hi,
yes I see. I tried again without the typo but it still didn't work
C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=C:\MySQL\include MYSQL_LIBDIR=C:\MySQL\lib C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>mingw32-make cd odbc\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\odbc\odbc.pro ) && mingw32-make -f Makefile mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make -f Makefile.Release all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make -f Makefile.Debug all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc' cd sqlite\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\sqlite\sqlite.pro ) && mingw32-make -f Makefile mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make -f Makefile.Release all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make -f Makefile.Debug all mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make[2]: Nothing to be done for 'all'. mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
for some reason it just doesn't go to mysql
-
Since qmake did not output anything according to your logs you should remove config.cache and start over (already told you above somewhere)
-
Since qmake did not output anything according to your logs you should remove config.cache and start over (already told you above somewhere)
@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 -
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