Qt MySQL Driver Mingw32-make not working
-
@hobbyProgrammer said in Qt MySQL Driver Mingw32-make not working:
liblibmysql.dll.a liblibmysql.a libmysql.dll.a libmysql.a libmysql.lib]
So is one of these libraries available in C:\Program Files (x86)\MySQL\MySQL Connector C++ 8.0\lib ? I would guess no. It's in C:\Program Files\MySQL\MySQL Server 8.0\lib or C:\Program Files (x86)\MySQL\MySQL Server 8.0\lib depending on what you've installed.
-
@Christian-Ehrlicher yes i know that these libraries are inside the MySQL Server 8.0 folder, but I don't know why it's not searching there. I used these commands: C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 8.0\include "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 8.0\lib"
I also moved the folder MySQL Server 8.0 to C:/MySQL, so I can access to a library without any spaces.
-
@hobbyProgrammer said in Qt MySQL Driver Mingw32-make not working:
C:\Program Files\MySQL\MySQL Server 8.0\include
put this in "" as it contains spaces
-
@jsulm just to be sure, it is just this command right?
qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 8.0\include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 8.0\lib"
not that I should add sqldrivers.pro behind it?
qmake -- "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 8.0\include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 8.0\lib" sqldrivers.pro
-
@hobbyProgrammer said in Qt MySQL Driver Mingw32-make not working:
not that I should add sqldrivers.pro behind it?
Depends in which directory you are. If you're in the directory where sqldrivers.pro is then no need to mention it. It looks like you're not doing out of source build which you should do. Also, are you sure qmake you're calling is the correct one (because you do not specify complete path)?
-
I had the same problem the other day.
qmake
refused to find the mysql libs for whatever reason.
So here's what I did:- cd into
C:/Qt/5.12.5/Src/qtbase
$> configure.exe -prefix C:\Qt\5.12.5\mingw73_32 -release -platform win32-g++ -sql-mysql MYSQL_INCDIR="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" MYSQL_LIBDIR="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib"
Adjust the prefix and mysql paths as needed.- If configure complains about
QMAKESPEC
and other variables - unset them; i.e.$> set QMAKESPEC=
- Rerun configure and make sure in the summary the mysql is detected
- Do a partial build of Qt:
$> mingw32-make module-qtbase
- Go to
C:/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers
and install the plugins in the prefix location:
mingw32-make install
Good luck.
PS. That's for a release build, for the debug version you need to set the appropriate flag to
configure
to build both. - cd into
-
@kshegunov I can't seem to find configure.exe, should it be .exe or can it also be a different type of file?
-
@hobbyProgrammer said in Qt MySQL Driver Mingw32-make not working:
I can't seem to find configure.exe, should it be .exe or can it also be a different type of file?
It's an exe. It's in your Qt source folder.
-
@kshegunov
I see 3 configure files:
config.txt
configure (which is labelled as 'file')
configure.bat
configure.json -
@kshegunov I tried with the .bat file, which seems to work properly, but I get this:
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
Which doesn't seem ideal.
Also when I checked it with a sql project I still got:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 -
@hobbyProgrammer said in Qt MySQL Driver Mingw32-make not working:
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
Then either you haven't provided the correct paths to the mysql headers and libraries or they're incompatible for some reason (e.g. they're 32bits while your compiler is 64bits or vice versa).
-
@kshegunov alright, I managed to get it right on my PC, but I'd also like to have it on my laptop. The reimp worked and the MySQL folder\lib now contains libmysql.def and libmysql.a, however whenever I run configure.exe it doesn't work.
configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -l mysql -I C:\MySQL\include -L C:\MySQL\lib
gives me this:
Bootstrapping qmake ... mingw32-make: Nothing to be done for 'first'. ERROR: Invalid value given for boolean command line option 'sql-mysql'. ERROR: Unknown command line option '-l'.
-
Hi,
As the error text suggests, remove that -l option. The configure script doesn't support it. It only wants the include and library paths.
-
@hobbyProgrammer Can you show your current configure call?
-
i tried:
configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -I C:\MySQL\include -L C:\MySQL\lib
which gave me this error:
ERROR: Invalid value given for boolean command line option 'sql-mysql'.
configure.exe -debug-and-release -platform win32-g++ -sql-mysql -I C:\MySQL\include -L C:\MySQL\lib
which gave me this error:
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
-
@hobbyProgrammer It should be -sql-mysql
Check the configure log to see what exactly is missing. -
I still don't understand why you try to compile Qt just to create the mysql plugin...
-
@Christian-Ehrlicher I am following this tutorial:
https://forum.qt.io/topic/40672/how-to-create-the-plugin-of-mysql-for-qt/34Should I just do the qmake for the sqldriver? or what else do you recommend?
so only qmake "MYSQL_INCDIR+=<path>" "MYSQL_LIBS+=<path>" ?