Solved Qt static with MySQL issue
-
@Cobra91151 said in Qt static with MySQL issue:
MT -lAdvapi32 -lUser32 -lCrypt32 -lGdi32
Many thanks for your instruction . As per your instruction i use below configure
configure -confirm-license -opensource -release -static -static-runtime -mp -platform win32-msvc -prefix "D:\QT\512M" -sql-mysql MYSQL_PREFIX="C:/mysql" MYSQL_LIBS="-lmysqlclient MT -lAdvapi32 -lUser32 -lCrypt32 -lGdi32" -gui -no-dbus -widgets -qt-zlib -qt-libjpeg -gif -ico -qt-libpng -qt-xkbcommon -qt-freetype -qt-pcre -qt-harfbuzz -opengl desktop -nomake tests -nomake examples -no-compile-examples -skip qttranslations -skip qtserialport -skip qtwebengine -recheck-all
check the config.log
there are no the error like below
LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
mysqlclient.lib(bchange.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(ctype-tis620.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(net_serv.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(client.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(mf_pack.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(mf_dirname.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(libmysql.obj) : warning LNK4217: 本地定义的符号 memmove 在函数 fetch_float_with_conversion 中导入
mysqlclient.lib(mf_format.obj) : warning LNK4049: 已导入本地定义的符号 memmove"these error in config.log file were gone.
now only 1 error show after configure comandline
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
anther question :
There is not blank before MT in your list command ?
Try to include to configure: MYSQL_LIBS="-lmysqlclientMT-lAdvapi32 -lUser32 -lCrypt32 -lGdi32" and also create a simple MySQL test project in VS 2017, for example console app to verify that it works: -
@Cobra91151
Cloud you give me a copy of mysqlclient.lib qsqlmysql.lib qsqlmysql.prl build by youself with vs2017 x64? my email tigerlfj@126.com
i think the mysqlclient.lib download from web is not for vs2017.
bast regards,
jeff -
Hi! I use
Qt 5.9.7
andOpenSSL libs: 1.0.2l
andMySQL: 5.7.23
because of the compatibility withWin Vista
and later. I think it should be better for you to use latest versions ofOpenSSL
andMySQL
to configureQt 5.12
.By the way,
mysqlclientMT
is the name of theMySQL
static lib compiled with/MT
flag.Change the instruction in configure to:
MYSQL_LIBS="-lmysqlclient -lAdvapi32 -lUser32 -lCrypt32 -lGdi32"
-
Also, this error:
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
points that yourMySQL
libs path is wrong in theQt
configure.For example:
my include path and libs path:-I "C:\MySQL\mysql-5.7.23-winx64\release\include" -L "C:\MySQL\mysql-5.7.23-winx64\release\lib"
Remove the
MYSQL_PREFIX="C:/mysql"
instruction and change to your paths appropriately.Also, I suggest you to create a batch script for
Qt
compilation. -
@Cobra91151
I try again and got the finally without error. but the qsqlmysql.lib is very small(only 798k).
can't use . -
Ok. Here are instructions how to build:
- Download the
MySQL
source from https://dev.mysql.com/downloads/mysql/ - Get the
OpenSSL
source from https://openssl.org/source/openssl-1.0.2l.tar.gz - Extract all archives
- Compile static
OpenSSL
- Compile static
MySQL
with previously compiledOpenSSL
libs
Read the
MySQL
andOpenSSL
(https://wiki.openssl.org/index.php/Compilation_and_Installation#PREFIX_and_OPENSSLDIR) docs for more details. - Download the
-
@Cobra91151
Many thanks for your help.
I will have a try. -
I use below steps and got the openssl
1:download openssl-1.0.2l
2: cd c:\openssl-10.2l
3:perl Configure VC-WIN64A no-asm --prefix=c:/QtOpenSSL64
4:ms\do_win64a
5:nmake -f ms\nt.mak
6: nmake -f ms\nt.mak test if dispaly passed all tests at last row means ok
7:nmake -f ms\nt.mak install
There are 2 libs in c:\QtOpenSSL64\lib libeay32.lib ssleay32.libI don't know how to next step mark in your instruction
5:Compile static MySQL with previously compiled OpenSSL libs
Cloud you give me more details?
Many thanks. -
@cawlfj
after got openssl by above 1-7.
8 :I download mysql connector c " mysql-connector-c-6.1.11-src.zip"
9: build it by cmake-gui and then got mysqlclient.lib
10: use below configure command, can see the openssl is yes but mysql is still erro
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.configure -confirm-license -opensource -release -static -static-runtime -mp -platform win32-msvc -prefix "D:\QT\512M" -openssl-linked OPENSSL_PREFIX=C:\QtOpenSSL64 OPENSSL_LIBS="-lssleay32 -llibeay32 -lgdi32" -sql-mysql MYSQL_PREFIX=C:\mysql MYSQL_LIBS="-lmysqlclient -lAdvapi32 -lUser32 -lCrypt32 -lGdi32" -gui -no-dbus -widgets -qt-zlib -qt-libjpeg -gif -ico -qt-libpng -qt-xkbcommon -qt-freetype -qt-pcre -qt-harfbuzz -opengl desktop -nomake tests -nomake examples -no-compile-examples -skip qttranslations -skip qtserialport -skip qtwebengine -recheck-all
-
Hi! The problem is that you use
MySQL
connector. But instead you should download this one:Extract it and build it with
OpenSSL
libs (which you previously built).Also read it:
@Cobra91151 said in Qt static with MySQL issue:
Also, this error:
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
points that yourMySQL
libs path is wrong in theQt
configure.For example:
my include path and libs path:-I "C:\MySQL\mysql-5.7.23-winx64\release\include" -L "C:\MySQL\mysql-5.7.23-winx64\release\lib"
Remove the
MYSQL_PREFIX="C:/mysql"
instruction and change to your paths appropriately.Also, I suggest you to create a batch script for
Qt
compilation. -
@Cobra91151
Dear Cobora91151
Use mysql connector c and modify the mysql_version.h.in to mysql_version.h
after configure , the mysql is display yes.
But after build whole qt , the qsqlmysql.lib is not present.
I will try mysql community server 8.0.13 . -
I never used
MySQL connector
, it's only confuses. OpenVS 2017 x64
command prompt and navigate to theMySQL
source dir and enter these instructions:cmake -DBUILD_SHARED_LIBS=OFF -DLINK_STATIC_RUNTIME_LIBRARIES=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST="C:\Boost" -DWITH_SSL="C:\OpenSSL\openssl-1.0.2l\x64\release" -DOPENSSL_LIBRARY="C:\OpenSSL\openssl-1.0.2l\x64\release\lib\ssleay32MT.lib" -DCRYPTO_LIBRARY="C:\OpenSSL\openssl-1.0.2l\x64\release\lib\libeay32MT.lib" -G "Visual Studio 15 2017 Win64"
Change all
OpenSSL
paths to appropriate yours and follow the instructions from the output. Then open compiled project in theVS 2017
and build it all. After that, you will seemysqlclient
lib.Note 1: The only
MySQL
static lib ismysqlclient.lib
Note 2: Check yourMySQL
libs are compiled with/MT
flags withVS 2017
and also before theQt compilation
I suggest to check if it works by creating simple console project.Happy New Year!
-
@Cobra91151
Dear Cobra91151
As per your instruction , i got mysqlclient.lib (seems it right 33m)
Now ,i am doing the command jom -j8 to get qt build.The version will be got in 2019.:)
Many thanks for your help!Happy New Year!
-
@Cobra91151
Happy New Year!
Many thanks for your help.
I got the right qsqlmysql.lib, now everything is ok!