PDA

View Full Version : Build the MySQL driver in QT 5.11



vovan1982
21st June 2018, 13:25
hello all can someone help me please
Sorry for my english

I can not compile the driver for MySql, read a lot of information

First I compiled qt 5.11 from the sources with the keys
-shared -debug-and-release -platform win32-g++ -prefix D:\Qt\5.11\5.11-x64 -opensource -confirm-license -c++std c++14 -nomake examples -skip wayland -skip purchasing -skip serialbus -skip qtserialport -skip script -skip scxml -skip speech -skip location -opengl desktop -qt-zlib -qt-pcre -qt-libpng -qt-freetype -openssl-linked -I D:\Qt\openssl-1.0.2\dist\include -L D:\Qt\openssl-1.0.2\dist\lib OPENSSL_LIBS="-llibssl -llibcrypto -luser32 -lgdi32 -lwsock32 -lws2_32"

Compiled on Windows 10 Pro x64. To compile, I used mingw-w64, also installed everything needed to build.

Downloaded and installed "MySQL Connector C 6.1", installed it into the C: \ MySql directory. (first installed the version of x64, but then after it did not work with it reinstalled on x86 and did all the work with it)

Then, as it is written in the official documentation http://doc.qt.io/qt-5/sql-driver.html#qmysql moved to the directory "%QTDIR%\qtbase\src\plugins\sqldrivers" and executed there
"qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/lib" "
mingw32-make sub-mysql

but got an error
"mingw32-make: *** No rule to make target 'sub-mysql'. Stop."

Looked at the Makefile, sub-mysql does not really exist there, if just do mingw32-make then the assembly of OBDC and SqlLite is going on, Mysql is not going to.

After that, I read a lot of information and found this resource https://mike-mvk.livejournal.com/4196.html in which they say that first need to convert libmysql.dll to libmysql.a, performed the transformation and repeated everything anew, the error is the same.
Then I tried to do as written on the specified resource
cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake -o Makefile "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MySQL\lib\libmysql.a" mysql.pro

but again got an error
Project ERROR: Library 'mysql' is not defined.

After that I decided to build QT already with MySql support, took clean sources and tried to configure with parameters
-shared -debug-and-release -platform win32-g++ -prefix D:\Qt\5.11\5.11-x64 -opensource -confirm-license -c++std c++14 -nomake examples -skip wayland -skip purchasing -skip serialbus -skip qtserialport -skip script -skip scxml -skip speech -skip location -opengl desktop -qt-zlib -qt-pcre -qt-libpng -no-libjpeg -qt-freetype -openssl-linked -I D:\Qt\openssl-1.0.2\dist\include -L D:\Qt\openssl-1.0.2\dist\lib OPENSSL_LIBS="-llibssl -llibcrypto -luser32 -lgdi32 -lwsock32 -lws2_32" -sql-mysql MYSQL_INCDIR=C:\MySQL\include MYSQL_LIBDIR=C:\MySQL\lib MYSQL_LIBS=-lmysqld

But when configuring, MySql does not pass "MySql .. no" and at the end there is an error message "ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed."

I decided to download qt-opensource-windows-x86-5.11.1.exe and compile the x86 version of the driver, because somewhere I read that it will work with x64, but got all the same errors.

Has anyone successfully assembled the MySql driver for Qt 5.11 or 5.10?
If you compiled, then tell me please, where there can be a mistake, re-read the entire Internet, none of the methods helped solve the problem.

sufyan
1st July 2018, 13:46
hy, i have same problem! did you find any solution?