Qt static with MySQL issue
-
Hi! I have built
Qt
statically withMySQL -sql-mysql
. Then I included library to the projectpro
file:LIBS += -L"C:/MySQL/mysql-5.7.22-win32/lib" -lmysqlclient
But it still requires
libmysql.dll
.Screenshot:
I use
mysqlclient
because info in theMySQL
docs states that this lib is static - http://ftp.nchu.edu.tw/MySQL/doc/refman/5.0/en/windows-client-compiling.htmlI also tried with
LIBS += -L"C:/MySQL/mysql-5.7.22-win32/lib" -llibmysql
but the same issue still exists. I want to have this library embedded into the executable. I have compiledQt 5.9.6
withmysql-5.7.22-win32
. Any ideas how to make it embedded? Thanks.
-
Hi,
That's likely because you are linking to the dynamic version of
libqmysqlclient
.Check that you really have a static version of the MySQL client library.
-
Hi! You are right. I have updated the
MySQL
tomysql-5.7.23
and run a few tests, then commented the code:#LIBS += -L"C:/MySQL/mysql-5.7.23-win32/lib" -llibmysql #LIBS += -L"C:/MySQL/mysql-5.7.23-win32/lib" -lmysqlclient
I get the issue:
:-1: error: LNK1181: cannot open input file 'C:\MySQL\mysql-5.7.22-win32\lib\libmysql.lib'
This means that
Qt
uses the wrongMySQL
lib (shared
). It should usemysqlclient
(static
). So I need to reconfigure it with lib path to exactly point to theC:\MySQL\mysql-5.7.23-win32\lib\mysqlclient.lib
static library or remove all the libs from the directory except for themysqlclient.lib
? Thanks.
-
Are you sure
C:\MySQL\mysql-5.7.23-win32\lib\mysqlclient.lib
is a static library ? The.lib
files can either be static libraries or import libraries.
-
Yes, I know, it could be static/shared library. I don't know 100% this library is static. But from
MySQL
docs:2.16.7. Compiling MySQL Clients on Windows ... You can either link your code with the dynamic libmysql.lib library, which is just a wrapper to load in libmysql.dll on demand, or link with the static mysqlclient.lib library. The MySQL client libraries are compiled as threaded libraries, so you should also compile your code to be multi-threaded.
It should be static. I will check it with
Visual Studio 2017
staticMFC
test project.
-
Are you looking at the latest version of the documentation ?
-
So, you are right! I have checked the
mysqlclient.lib
usingVS 2017
staticMFC
test project and I get the issues:It means this library is a
dynamic
. So where to get the static library or source files to build this library as static? Thanks.
-
MT and MD are just related to the Windows runtime type you'll be using.
-
I have checked it using
lib /list mysqlclient.lib
and7zip
, it displayed:This means the library is 100% static. So how to add it to
Qt
during reconfiguration? Should I provide full path to the library or remove all libs exceptmysqlclient.lib
and provide path? Thanks.
-
Can you show which configuration options you used ?
-
Ok, my batch file:
SET /P qtBuildType=Qt build type (shared/static): SET /P qtBuildMySqlIncludePath=MySql include path: SET /P qtBuildMySqlLibPath=MySql lib path: SET /P qtBuildOpenSSLIncludePath=OpenSSL include path: SET /P qtBuildOpenSSLLibPath=OpenSSL lib path: SET /P qtBuildPath=Enter Qt build path: configure.bat -debug-and-release -%qtBuildType% -opensource -nomake tools -nomake examples -no-ltcg -sql-mysql -I "%qtBuildMySqlIncludePath%" -L "%qtBuildMySqlLibPath%" -ssl -openssl -openssl-linked -I "%qtBuildOpenSSLIncludePath%" -L "%qtBuildOpenSSLLibPath%" OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MTd -llibeay32MTd" OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT" -prefix "%qtBuildPath%"
For example,
MySql
include path was :C:\MySQL\mysql-5.7.22-win32\include
andMySql
lib pathC:\MySQL\mysql-5.7.22-win32\lib
but it makeQt
to useC:\MySQL\mysql-5.7.22-win32\lib\libmysql.lib
(dynamic). I think, should be another way to set proper library.
-
I would add
MYSQL_LIBS=-lmysqlclient
.
-
Ok. I will try it and reply. Thanks.
-
I added the
MYSQL_LIBS="-lmysqlclient"
to configure:configure.bat -debug-and-release -%qtBuildType% -opensource -nomake tools -nomake examples -no-ltcg -sql-mysql -I "%qtBuildMySqlIncludePath%" -L "%qtBuildMySqlLibPath%" MYSQL_LIBS="-lmysqlclient" -ssl -openssl -openssl-linked -I "%qtBuildOpenSSLIncludePath%" -L "%qtBuildOpenSSLLibPath%" OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MTd -llibeay32MTd" OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT" -prefix "%qtBuildPath%"
But I get the issue:
I think I should also provide the
libmysql
toMYSQL_LIBS
or the problem is withmysql-5.7.23
.
-
I have found the issue! Adding this line
MYSQL_LIBS="-lmysqlclient"
to configure for some reason breaks the detection ofMySQL
. I will try again to confirm it.
-
Yes, I was right. Adding
MYSQL_LIBS="-lmysqlclient"
breaks the detection ofMySQL
- 100% confirmed.
-
I run a few tests and found that
Qt
requireslibmysql.lib
to configure, but since itdynamic
lib it won't work in my case. I think I should try to renamemysqlclient.lib
tolibmysql.lib
and test it.
-
No, it fails with detection the
MySQL
iflibmysql.lib
has been changed, renamed or removed.
-
I think I have found the issue.
This line of code in the file -
configure.json
-{ "libs": "-lmysqlclient", "condition": "!config.win32" }
disablesmysqlclient
(static) lib because condition states that!win32
, means notWindows
system. I will change it and try again.
-
I have tried different solutions but it all failed.
The config.log:
+ cd /d D:\QtBuild\Src\config.tests\mysql && D:\QtBuild\Src\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" "QMAKE_LIBDIR += C:\\MySQL\\mysql-5.7.23-win32\\lib C:\\OpenSSL\\openssl-1.0.2l-vs2017\\lib" "INCLUDEPATH += C:\\MySQL\\mysql-5.7.23-win32\\include C:\\OpenSSL\\openssl-1.0.2l-vs2017\\include" "LIBS += -lmysqlclient" D:/QtBuild/Src/config.tests/mysql + cd /d D:\QtBuild\Src\config.tests\mysql && set MAKEFLAGS=& nmake > Microsoft (R) Program Maintenance Utility Version 14.15.26726.0 > Copyright (C) Microsoft Corporation. All rights reserved. > cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zi -MDd -W0 -EHsc /Fdmysql.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\MySQL\mysql-5.7.23-win32\include -IC:\OpenSSL\openssl-1.0.2l-vs2017\include -ID:\QtBuild\Src\qtbase\mkspecs\win32-msvc -Fo @C:\Users\cobra\AppData\Local\Temp\nmC064.tmp > main.cpp > link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:mysql.exe @C:\Users\cobra\AppData\Local\Temp\nmC2B7.tmp > LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library > mysqlclient.lib(xml.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(libmysql.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(my_time.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(client.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(ctype.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _win32_have_tcpip > mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegEnumValueA@32 referenced in function _win_init_registry > mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _win32_have_tcpip > mysqlclient.lib(my_default.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(log_client.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_winfile.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_mess.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_mess.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _my_message_stderr > mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol __imp__fprintf > mysqlclient.lib(log_client.obj) : error LNK2001: unresolved external symbol __imp__fprintf > mysqlclient.lib(client_authentication.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::_System_error_category::message(int)const " (?message@_System_error_category@std@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@H@Z) > mysqlclient.lib(sha2_password_common.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) > mysqlclient.lib(my_default.obj) : error LNK2019: unresolved external symbol __imp__printf referenced in function _my_load_defaults > mysqlclient.lib(ssl.obj) : error LNK2019: unresolved external symbol __imp___snprintf referenced in function _ya_SSL_ASN1_TIME_to_string > mysqlclient.lib(log_client.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function "void __cdecl error_log_vprint(enum error_log_level::type,char const *,char *)" (?error_log_vprint@@YAXW4type@error_log_level@@PBDPAD@Z) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__EqualSid@8 referenced in function "public: bool __thiscall Sid::operator==(class Sid const &)" (??8Sid@@QAE_NABV0@@Z) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__GetTokenInformation@20 referenced in function "public: __thiscall Sid::Sid(void *)" (??0Sid@@QAE@PAX@Z) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__IsValidSid@4 referenced in function "public: bool __thiscall Sid::is_valid(void)const " (?is_valid@Sid@@QBE_NXZ) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__LookupAccountNameW@28 referenced in function "public: __thiscall Sid::Sid(wchar_t const *)" (??0Sid@@QAE@PB_W@Z) > mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptAcquireContextA@20 referenced in function "public: __thiscall TaoCrypt::OS_Seed::OS_Seed(void)" (??0OS_Seed@TaoCrypt@@QAE@XZ) > mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptReleaseContext@8 referenced in function "public: __thiscall TaoCrypt::OS_Seed::~OS_Seed(void)" (??1OS_Seed@TaoCrypt@@QAE@XZ) > mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptGenRandom@12 referenced in function "public: void __thiscall TaoCrypt::OS_Seed::GenerateSeed(unsigned char *,unsigned int)" (?GenerateSeed@OS_Seed@TaoCrypt@@QAEXPAEI@Z) > mysql.exe : fatal error LNK1120: 17 unresolved externals > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\link.EXE"' : return code '0x460' > Stop. => source failed verification. Trying source 6 (type inline) of library mysql ... + cd /d D:\QtBuild\Src\config.tests\mysql && D:\QtBuild\Src\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" "QMAKE_LIBDIR += C:\\MySQL\\mysql-5.7.23-win32\\lib C:\\OpenSSL\\openssl-1.0.2l-vs2017\\lib" "INCLUDEPATH += C:\\MySQL\\mysql-5.7.23-win32\\include C:\\OpenSSL\\openssl-1.0.2l-vs2017\\include" "LIBS += -lmysqlclient" D:/QtBuild/Src/config.tests/mysql + cd /d D:\QtBuild\Src\config.tests\mysql && set MAKEFLAGS=& nmake clean && set MAKEFLAGS=& nmake > Microsoft (R) Program Maintenance Utility Version 14.15.26726.0 > Copyright (C) Microsoft Corporation. All rights reserved. > del main.obj > del mysql.vc.pdb mysql.ilk mysql.idb > Microsoft (R) Program Maintenance Utility Version 14.15.26726.0 > Copyright (C) Microsoft Corporation. All rights reserved. > cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zi -MDd -W0 -EHsc /Fdmysql.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\MySQL\mysql-5.7.23-win32\include -IC:\OpenSSL\openssl-1.0.2l-vs2017\include -ID:\QtBuild\Src\qtbase\mkspecs\win32-msvc -Fo @C:\Users\cobra\AppData\Local\Temp\nmC3CF.tmp > main.cpp > link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:mysql.exe @C:\Users\cobra\AppData\Local\Temp\nmC632.tmp > LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library > mysqlclient.lib(xml.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(libmysql.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(my_time.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(client.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(ctype.obj) : error LNK2001: unresolved external symbol __imp__sprintf > mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _win32_have_tcpip > mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegEnumValueA@32 referenced in function _win_init_registry > mysqlclient.lib(my_init.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _win32_have_tcpip > mysqlclient.lib(my_default.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(log_client.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_winfile.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_mess.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol __imp____iob_func > mysqlclient.lib(my_mess.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _my_message_stderr > mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol __imp__fprintf > mysqlclient.lib(log_client.obj) : error LNK2001: unresolved external symbol __imp__fprintf > mysqlclient.lib(client_authentication.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::_System_error_category::message(int)const " (?message@_System_error_category@std@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@H@Z) > mysqlclient.lib(sha2_password_common.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) > mysqlclient.lib(my_default.obj) : error LNK2019: unresolved external symbol __imp__printf referenced in function _my_load_defaults > mysqlclient.lib(ssl.obj) : error LNK2019: unresolved external symbol __imp___snprintf referenced in function _ya_SSL_ASN1_TIME_to_string > mysqlclient.lib(log_client.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function "void __cdecl error_log_vprint(enum error_log_level::type,char const *,char *)" (?error_log_vprint@@YAXW4type@error_log_level@@PBDPAD@Z) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__EqualSid@8 referenced in function "public: bool __thiscall Sid::operator==(class Sid const &)" (??8Sid@@QAE_NABV0@@Z) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__GetTokenInformation@20 referenced in function "public: __thiscall Sid::Sid(void *)" (??0Sid@@QAE@PAX@Z) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__IsValidSid@4 referenced in function "public: bool __thiscall Sid::is_valid(void)const " (?is_valid@Sid@@QBE_NXZ) > mysqlclient.lib(common.obj) : error LNK2019: unresolved external symbol __imp__LookupAccountNameW@28 referenced in function "public: __thiscall Sid::Sid(wchar_t const *)" (??0Sid@@QAE@PB_W@Z) > mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptAcquireContextA@20 referenced in function "public: __thiscall TaoCrypt::OS_Seed::OS_Seed(void)" (??0OS_Seed@TaoCrypt@@QAE@XZ) > mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptReleaseContext@8 referenced in function "public: __thiscall TaoCrypt::OS_Seed::~OS_Seed(void)" (??1OS_Seed@TaoCrypt@@QAE@XZ) > mysqlclient.lib(random.obj) : error LNK2019: unresolved external symbol __imp__CryptGenRandom@12 referenced in function "public: void __thiscall TaoCrypt::OS_Seed::GenerateSeed(unsigned char *,unsigned int)" (?GenerateSeed@OS_Seed@TaoCrypt@@QAEXPAEI@Z) > mysql.exe : fatal error LNK1120: 17 unresolved externals > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\link.EXE"' : return code '0x460' > Stop. => source failed verification. test config.sqldrivers.libraries.mysql FAILED looking for library oci Trying source 0 (type inline) of library oci ... + cd /d D:\QtBuild\Src\config.tests\oci && D:\QtBuild\Src\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" "QMAKE_LIBDIR += C:\\MySQL\\mysql-5.7.23-win32\\lib C:\\OpenSSL\\openssl-1.0.2l-vs2017\\lib" "INCLUDEPATH += C:\\MySQL\\mysql-5.7.23-win32\\include C:\\OpenSSL\\openssl-1.0.2l-vs2017\\include" "LIBS += -loci" D:/QtBuild/Src/config.tests/oci + cd /d D:\QtBuild\Src\config.tests\oci && set MAKEFLAGS=& nmake > Microsoft (R) Program Maintenance Utility Version 14.15.26726.0 > Copyright (C) Microsoft Corporation. All rights reserved. > cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zi -MDd -W0 -EHsc /Fdoci.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\MySQL\mysql-5.7.23-win32\include -IC:\OpenSSL\openssl-1.0.2l-vs2017\include -ID:\QtBuild\Src\qtbase\mkspecs\win32-msvc -Fo @C:\Users\cobra\AppData\Local\Temp\nmC6EC.tmp > main.cpp > .\main.cpp(2): fatal error C1083: Cannot open include file: 'oci.h': No such file or directory > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\cl.EXE"' : return code '0x2' > Stop.
Any ideas how to make it compile with the
static
library? Thanks.
-
@SGaist said in Qt static with MySQL issue:
MT and MD are just related to the Windows runtime type you'll be using.
The issue must be with this. I checked
Qt
configure log and the same errors are displayed withMFC
static test project inVS 2017
.LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library 1>mysqlclient.lib(xml.obj) : error LNK2001: unresolved external symbol __imp__sprintf 1>mysqlclient.lib(libmysql.obj) : error LNK2001: unresolved external symbol __imp__sprintf 1>mysqlclient.lib(my_time.obj) : error LNK2001: unresolved external symbol __imp__sprintf 1>mysqlclient.lib(client.obj) : error LNK2001: unresolved external symbol __imp__sprintf 1>mysqlclient.lib(ctype.obj) : error LNK2001: unresolved external symbol __imp__sprintf 1>mysqlclient.lib(my_error.obj) : error LNK2001: unresolved external symbol __imp__strcat_s 1>mysqlclient.lib(my_error.obj) : error LNK2001: unresolved external symbol __imp__strerror_s 1>mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp__strdup 1>mysqlclient.lib(yassl_int.obj) : error LNK2001: unresolved external symbol __imp__strdup 1>OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp__strdup 1>mysqlclient.lib(my_default.obj) : error LNK2001: unresolved external symbol __imp____iob_func 1>mysqlclient.lib(log_client.obj) : error LNK2001: unresolved external symbol __imp____iob_func 1>mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____iob_func 1>mysqlclient.lib(my_winfile.obj) : error LNK2001: unresolved external symbol __imp____iob_func 1>mysqlclient.lib(my_mess.obj) : error LNK2001: unresolved external symbol __imp____iob_func 1>mysqlclient.lib(typelib.obj) : error LNK2001: unresolved external symbol __imp____iob_func 1>mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp__putenv
It leads to
Qt
configure errors. For some reason it conflicts withMSVCRT
lib.
-
I have run some tests on another PC, the same errors are present there. So, I think the
mysqlclient
is build for another compiler, maybe,MinGW
or olderVS
versions. I need to find theMySQL
source code and compilemysqlclient
(static) lib forVisual Studio 2017
. Any ideas where I can find it? Thanks.
-
I have found the source code here: https://dev.mysql.com/downloads/mysql/
Now I will read docs how to compile it.
-
I have built the
MySQL
libs, added to theMFC
test project and it displays the same errors. It's strange. Next, I will install virtual machine,VS 2015
and build the test project there.
-
I have found the issue and built the
MySQL
libs. Then I reconfigureQt
, all built well but when I build my project I get the issue:So,
mysqlclient.lib
already has theOpenSSL
?Also, I have the issue with debugging the app:
I have the debug version of the library, but I want to know how to add it to the
configure
? I have tried:MYSQL_LIBS_DEBUG/MYSQL_LIBS_RELEASE
but it fails with detection ofMySQL
. Any ideas? Thanks.
-
I have found that I must have the
OpenSSL
built statically as/MD
runtime lib in order to compile my project. The question is where to get such library or source code? Thanks in advance.
-
I have fixed the issue with
MYSQL_LIBS_DEBUG/MYSQL_LIBS_RELEASE
libs by creating the advanced batch script file. So, it compiles thedebug/release
separately, has a support to removeQt
source dir and unpack the source from archive usingWinRaR
for the next compilation.By the way, I get issue when building static
Qt
in thedebug
mode:By pressing
Retry
it continues to buildQt
successfully.Still one more issue to fix:
-
So, I have fixed the issue:
Solution:
OpenSSL source code: 1.1.1
MySQL source code: 5.7.23- Compile static
OpenSSL
libs with/MDd
|/MD
flags forDebug
/Release
mode - Compile
MySQL
static libs (/MDd
|/MD
) with pre-compiledOpenSSL
static libs (option 1)
I test it in the simple console app in the
Visual Studio 2017
:Code:
#include <iostream> #include <mysql.h> #include <openssl/bio.h> #include <openssl/ssl.h> #include <openssl/err.h> using namespace std; int main() { cout << "Hello World!" << endl; cout << "Hello!" << endl; SSL_load_error_strings(); ERR_load_BIO_strings(); OpenSSL_add_all_algorithms(); printf("MySQL client version: %s\n", mysql_get_client_info()); system("PAUSE"); return 0; }
The result:
Now I configure Qt statically with these libs (
MySQL & OpenSSL
), first in theDebug
mode. It findMySQL
andOpenSSL
during configuration but then I get this issue:The question is how to fix this issue with
Qt
? Thanks in advance.
- Compile static
-
This post is deleted!
-
My issue is not solved because
Qt
for some reason doesn't build it. The question is why it can't build it properly now?
-
I think that
Qt
is not compatible with the followingOpenSSL
libs:- libcrypto.lib
- libssl.lib
-
OpenSSL .1.1.X is supported since Qt 5.10.
-
Finally, I have fixed the issue.
Solution:
I built the static
OpenSSL
libs: 1.0.2l andMySQL
:5.7.23
static libs with pre-built earlyOpenSSL
libs providing the flag:-DCRYPTO_LIBRARY="path to lib\libeay32MD.lib"
to thecmake
, becauselibeay32
corresponds tolibcrypto
.I reconfigured the
Qt
statically with these static libs. Now it works forx86
andx64
and these libs are embedded into the executable. The issue is resolved.
-
@Cobra91151
could you send a copy static libs(mysqlclient.lib \qsqlmysql.lib build with vs2017 MT)?
Or give me a details of build it and qsqlmysql.lib with vs2017 on windows10, i want to build it by QT5.12 .
Many thanks for your help!
jeff
-
@Cobra91151
I used below configureconfigure -confirm-license -opensource -release -static -static-runtime -mp -platform win32-msvc -prefix "D:\QT\512M" -sql-mysql MYSQL_PREFIX="C:/mysql" MYSQL_LIBS="-lmysqlclient" -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
and got
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.in config.log found below information about mysql:
cd /d C:\Qt\Qt5.12.0\5.12.0\Src\config.tests\mysql && C:\Qt\Qt5.12.0\5.12.0\Src\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" "QMAKE_USE += mysql" "QMAKE_LIBS_MYSQL = -LC:/mysql/lib -lmysqlclient" "QMAKE_INCDIR_MYSQL = C:/mysql/include" C:/Qt/Qt5.12.0/5.12.0/Src/config.tests/mysql
-
cd /d C:\Qt\Qt5.12.0\5.12.0\Src\config.tests\mysql && set MAKEFLAGS=& nmake clean && set MAKEFLAGS=& nmake
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MT -W0 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DNDEBUG -I. -IC:\mysql\include -IC:\Qt\Qt5.12.0\5.12.0\Src\qtbase\mkspecs\win32-msvc -Fo @C:\Users\jeff\AppData\Local\Temp\nmAAE6.tmp
main.cpp
link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /OUT:mysql.exe @C:\Users\jeff\AppData\Local\Temp\nmACDB.tmp
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
mysqlclient.lib(my_time.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(my_vsnprintf.obj) : warning LNK4049: 已导入本地定义的符号 memmove
mysqlclient.lib(ssl.obj) : warning LNK4049: 已导入本地定义的符号 __stdio_common_vsprintf
mysqlclient.lib(xml.obj) : warning LNK4049: 已导入本地定义的符号 __stdio_common_vsprintf
mysqlclient.lib(libmysql.obj) : warning LNK4217: 本地定义的符号 __stdio_common_vsprintf 在函数 sprintf 中导入
mysqlclient.lib(my_time.obj) : warning LNK4049: 已导入本地定义的符号 __stdio_common_vsprintf
mysqlclient.lib(client.obj) : warning LNK4049: 已导入本地定义的符号 __stdio_common_vsprintf
mysqlclient.lib(ctype.obj) : warning LNK4217: 本地定义的符号 __stdio_common_vsprintf 在函数 cs_leave 中导入
mysqlclient.lib(libmysql.obj) : warning LNK4217: 本地定义的符号 atoi 在函数 mysql_server_init 中导入
mysqlclient.lib(client.obj) : warning LNK4049: 已导入本地定义的符号 atoi
mysqlclient.lib(typelib.obj) : warning LNK4049: 已导入本地定义的符号 atoi
mysqlclient.lib(handshake_client.obj) : warning LNK4049: 已导入本地定义的符号 atoi
mysqlclient.lib(my_thr_init.obj) : warning LNK4217: 本地定义的符号 _set_abort_behavior 在函数 my_thread_init 中导入
mysqlclient.lib(my_thr_init.obj) : warning LNK4217: 本地定义的符号 signal 在函数 my_thread_init 中导入
mysqlclient.lib(my_fstream.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(crypt_genhash_impl.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(my_fopen.obj) : warning LNK4217: 本地定义的符号 _errno 在函数 my_win_freopen 中导入
mysqlclient.lib(my_thread.obj) : warning LNK4217: 本地定义的符号 _errno 在函数 my_thread_create 中导入
mysqlclient.lib(my_lib.obj) : warning LNK4217: 本地定义的符号 _errno 在函数 my_dir 中导入
mysqlclient.lib(my_access.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(my_winerr.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(my_winfile.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(my_once.obj) : warning LNK4217: 本地定义的符号 _errno 在函数 my_once_alloc 中导入
mysqlclient.lib(str2int.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(my_getwd.obj) : warning LNK4217: 本地定义的符号 _errno 在函数 my_getwd 中导入
mysqlclient.lib(my_malloc.obj) : warning LNK4217: 本地定义的符号 _errno 在函数 my_raw_malloc 中导入
mysqlclient.lib(my_open.obj) : warning LNK4217: 本地定义的符号 _errno 在函数 my_close 中导入
mysqlclient.lib(my_read.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(client.obj) : warning LNK4049: 已导入本地定义的符号 _errno
mysqlclient.lib(my_malloc.obj) : warning LNK4217: 本地定义的符号 calloc 在函数 my_raw_malloc 中导入
mysqlclient.lib(zutil.obj) : warning LNK4049: 已导入本地定义的符号 free
mysqlclient.lib(yassl_int.obj) : warning LNK4217: 本地定义的符号 free 在函数 "public: void __cdecl yaSSL::SSL::makeTLSMasterSecret(void)" (?makeTLSMasterSecret@SSL@yaSSL@@QEAAXXZ) 中导入
mysqlclient.lib(handshake_client.obj) : warning LNK4049: 已导入本地定义的符号 free
mysqlclient.lib(str_alloc.obj) : warning LNK4049: 已导入本地定义的符号 free
mysqlclient.lib(common.obj) : warning LNK4049: 已导入本地定义的符号 free
mysqlclient.lib(my_malloc.obj) : warning LNK4217: 本地定义的符号 free 在函数 my_free 中导入
mysqlclient.lib(dtoa.obj) : warning LNK4049: 已导入本地定义的符号 free
mysqlclient.lib(my_once.obj) : warning LNK4049: 已导入本地定义的符号 free
mysqlclient.lib(my_thread.obj) : warning LNK4049: 已导入本地定义的符号 free
mysqlclient.lib(ssl.obj) : warning LNK4049: 已导入本地定义的符号 malloc
mysqlclient.lib(str_alloc.obj) : warning LNK4049: 已导入本地定义的符号 malloc
mysqlclient.lib(common.obj) : warning LNK4049: 已导入本地定义的符号 malloc
mysqlclient.lib(zutil.obj) : warning LNK4049: 已导入本地定义的符号 malloc
mysqlclient.lib(my_malloc.obj) : warning LNK4217: 本地定义的符号 malloc 在函数 my_raw_malloc 中导入
mysqlclient.lib(dtoa.obj) : warning LNK4049: 已导入本地定义的符号 malloc
mysqlclient.lib(my_once.obj) : warning LNK4049: 已导入本地定义的符号 malloc
mysqlclient.lib(my_thread.obj) : warning LNK4049: 已导入本地定义的符号 malloc
mysqlclient.lib(str_alloc.obj) : warning LNK4049: 已导入本地定义的符号 exit
mysqlclient.lib(my_malloc.obj) : warning LNK4217: 本地定义的符号 exit 在函数 my_raw_malloc 中导入
mysqlclient.lib(client.obj) : warning LNK4049: 已导入本地定义的符号 exit
mysqlclient.lib(typelib.obj) : warning LNK4049: 已导入本地定义的符号 exit
mysqlclient.lib(my_default.obj) : warning LNK4049: 已导入本地定义的符号 exit
mysqlclient.lib(my_default.obj) : warning LNK4049: 已导入本地定义的符号 __acrt_iob_func
mysqlclient.lib(log_client.obj) : warning LNK4049: 已导入本地定义的符号 __acrt_iob_func
mysqlclient.lib(my_init.obj) : warning LNK4217: 本地定义的符号 __acrt_iob_func 在函数 my_end 中导入
mysqlclient.lib(my_winfile.obj) : warning LNK4049: 已导入本地定义的符号 __acrt_iob_func
mysqlclient.lib(my_mess.obj) : warning LNK4049: 已导入本地定义的符号 __acrt_iob_func
mysqlclient.lib(typelib.obj) : warning LNK4217: 本地定义的符号 __acrt_iob_func 在函数 find_type_or_exit 中导入
mysqlclient.lib(my_init.obj) : warning LNK4217: 本地定义的符号 _set_invalid_parameter_handler 在函数 my_init 中导入
mysqlclient.lib(crypt_genhash_impl.obj) : warning LNK4049: 已导入本地定义的符号 strchr
mysqlclient.lib(ctype.obj) : warning LNK4217: 本地定义的符号 strchr 在函数 cs_file_sec 中导入
mysqlclient.lib(my_default.obj) : warning LNK4049: 已导入本地定义的符号 strchr
mysqlclient.lib(my_access.obj) : warning LNK4049: 已导入本地定义的符号 strchr
mysqlclient.lib(xml.obj) : warning LNK4049: 已导入本地定义的符号 strchr
mysqlclient.lib(mf_format.obj) : warning LNK4217: 本地定义的符号 strchr 在函数 fn_format 中导入
mysqlclient.lib(client_plugin.obj) : warning LNK4049: 已导入本地定义的符号 strchr
mysqlclient.lib(my_winfile.obj) : warning LNK4049: 已导入本地定义的符号 strchr
mysqlclient.lib(my_getwd.obj) : warning LNK4049: 已导入本地定义的符号 strchr
mysqlclient.lib(charset.obj) : warning LNK4217: 本地定义的符号 _strnicmp 在函数 get_collation_number 中导入
mysqlclient.lib(ctype-uca.obj) : warning LNK4049: 已导入本地定义的符号 _strnicmp
mysqlclient.lib(handshake_client.obj) : warning LNK4049: 已导入本地定义的符号 _strnicmp
mysqlclient.lib(my_vsnprintf.obj) : warning LNK4217: 本地定义的符号 strnlen 在函数 process_str_arg 中导入
mysqlclient.lib(yassl_int.obj) : warning LNK4049: 已导入本地定义的符号 strncmp
mysqlclient.lib(crypt_genhash_impl.obj) : warning LNK4049: 已导入本地定义的符号 strncmp
mysqlclient.lib(handshake.obj) : warning LNK4049: 已导入本地定义的符号 strncmp
mysqlclient.lib(crypto_wrapper.obj) : warning LNK4217: 本地定义的符号 strncmp 在函数 "unsigned char * __cdecl TaoCrypt::StdReallocate<unsigned char,class TaoCrypt::AllocatorWithCleanup<unsigned char> >(class TaoCrypt::AllocatorWithCleanup<unsigned char> &,unsigned char *,unsigned __int64,unsigned __int64,bool)" (??$StdReallocate@EV?$AllocatorWithCleanup@E@TaoCrypt@@@TaoCrypt@@YAPEAEAEAV?$AllocatorWithCleanup@E@0@PEAE_K2_N@Z) 中导入
mysqlclient.lib(client.obj) : warning LNK4217: 本地定义的符号 strncmp 在函数 read_ok_ex 中导入
mysqlclient.lib(ctype.obj) : warning LNK4217: 本地定义的符号 strncmp 在函数 cs_value 中导入
mysqlclient.lib(my_default.obj) : warning LNK4049: 已导入本地定义的符号 strncmp
mysqlclient.lib(ssl.obj) : warning LNK4049: 已导入本地定义的符号 strncmp
mysqlclient.lib(client.obj) : warning LNK4217: 本地定义的符号 strtoul 在函数 mysql_get_server_version 中导入
mysqlclient.lib(ctype.obj) : warning LNK4049: 已导入本地定义的符号 strtoul
mysqlclient.lib(my_winfile.obj) : warning LNK4217: 本地定义的符号 _close 在函数 my_win_fstat 中导入
mysqlclient.lib(my_fopen.obj) : warning LNK4049: 已导入本地定义的符号 _close
mysqlclient.lib(my_winfile.obj) : warning LNK4217: 本地定义的符号 _get_osfhandle 在函数 my_win_fileno 中导入
mysqlclient.lib(my_winfile.obj) : warning LNK4217: 本地定义的符号 _open_osfhandle 在函数 my_win_fdopen 中导入
mysqlclient.lib(my_fopen.obj) : warning LNK4049: 已导入本地定义的符号 _open_osfhandle
mysqlclient.lib(my_winfile.obj) : warning LNK4217: 本地定义的符号 fclose 在函数 my_win_fclose 中导入
mysqlclient.lib(ssl.obj) : warning LNK4049: 已导入本地定义的符号 fclose
mysqlclient.lib(file.obj) : warning LNK4049: 已导入本地定义的符号 fclose
mysqlclient.lib(my_mess.obj) : warning LNK4217: 本地定义的符号 strrchr 在函数 my_message_stderr 中导入
mysqlclient.lib(mf_pack.obj) : warning LNK4049: 已导入本地定义的符号 strrchr
mysqlclient.lib(mf_dirname.obj) : warning LNK4217: 本地定义的符号 strrchr 在函数 convert_dirname 中导入
mysqlclient.lib(mf_fn_ext.obj) : warning LNK4049: 已导入本地定义的符号 strrchr
mysqlclient.lib(my_mess.obj) : warning LNK4217: 本地定义的符号 fflush 在函数 my_message_stderr 中导入
mysqlclient.lib(log_client.obj) : warning LNK4049: 已导入本地定义的符号 fflush
mysqlclient.lib(my_mess.obj) : warning LNK4217: 本地定义的符号 fputc 在函数 my_message_stderr 中导入
mysqlclient.lib(my_default.obj) : warning LNK4049: 已导入本地定义的符号 fputc
mysqlclient.lib(log_client.obj) : warning LNK4049: 已导入本地定义的符号 fputc
mysqlclient.lib(my_mess.obj) : warning LNK4217: 本地定义的符号 __stdio_common_vfprintf 在函数 fprintf 中导入
mysqlclient.lib(typelib.obj) : warning LNK4217: 本地定义的符号 __stdio_common_vfprintf 在函数 find_set_from_flags 中导入
mysqlclient.lib(my_default.obj) : warning LNK4049: 已导入本地定义的符号 __stdio_common_vfprintf
mysqlclient.lib(log_client.obj) : warning LNK4217: 本地定义的符号 __stdio_common_vfprintf 在函数 "void __cdecl error_log_vprint(enum error_log_level::type,char const *,char *)" (?error_log_vprint@@YAXW4type@error_log_level@@PEBDPEAD@Z) 中导入
mysqlclient.lib(ctype.obj) : warning LNK4217: 本地定义的符号 strtol 在函数 cs_value 中导入
mysqlclient.lib(viosocket.obj) : warning LNK4049: 已导入本地定义的符号 strtol
mysqlclient.lib(crypt_genhash_impl.obj) : warning LNK4049: 已导入本地定义的符号 strtol
mysqlclient.lib(ctype-simple.obj) : warning LNK4217: 本地定义的符号 qsort 在函数 create_fromuni 中导入
mysqlclient.lib(my_access.obj) : warning LNK4217: 本地定义的符号 toupper 在函数 check_if_legal_filename 中导入
mysqlclient.lib(my_fopen.obj) : warning LNK4217: 本地定义的符号 _fileno 在函数 my_win_freopen 中导入
OLDNAMES.lib(fileno.obi) : warning LNK4049: 已导入本地定义的符号 _fileno
mysqlclient.lib(get_password.obj) : warning LNK4217: 本地定义的符号 isspace 在函数 yassl_mysql_get_tty_password_ext 中导入
mysqlclient.lib(get_password.obj) : warning LNK4217: 本地定义的符号 iscntrl 在函数 yassl_mysql_get_tty_password_ext 中导入
mysqlclient.lib(my_default.obj) : error LNK2001: 无法解析的外部符号 __imp_getenv
mysqlclient.lib(handshake_client.obj) : error LNK2001: 无法解析的外部符号 __imp_getenv
mysqlclient.lib(libmysql.obj) : error LNK2001: 无法解析的外部符号 __imp_getenv
mysqlclient.lib(my_init.obj) : error LNK2001: 无法解析的外部符号 __imp_getenv
mysqlclient.lib(client.obj) : error LNK2001: 无法解析的外部符号 __imp_getenv
mysqlclient.lib(client_plugin.obj) : error LNK2001: 无法解析的外部符号 __imp_getenv
mysqlclient.lib(my_malloc.obj) : error LNK2019: 无法解析的外部符号 __imp_realloc,该符号在函数 my_raw_realloc 中被引用
mysqlclient.lib(str_alloc.obj) : error LNK2001: 无法解析的外部符号 __imp_realloc
mysqlclient.lib(my_error.obj) : error LNK2019: 无法解析的外部符号 __imp_strcat_s,该符号在函数 my_strerror 中被引用
mysqlclient.lib(my_error.obj) : error LNK2019: 无法解析的外部符号 __imp_strerror_s,该符号在函数 my_strerror 中被引用
mysqlclient.lib(my_init.obj) : error LNK2019: 无法解析的外部符号 __imp_strdup,该符号在函数 win_init_registry 中被引用
mysqlclient.lib(yassl_int.obj) : error LNK2001: 无法解析的外部符号 __imp_strdup
OLDNAMES.lib(strdup.obi) : error LNK2001: 无法解析的外部符号 __imp_strdup
mysqlclient.lib(my_init.obj) : error LNK2019: 无法解析的外部符号 __imp_RegCloseKey,该符号在函数 win32_have_tcpip 中被引用
mysqlclient.lib(my_init.obj) : error LNK2019: 无法解析的外部符号 __imp_RegEnumValueA,该符号在函数 win_init_registry 中被引用
mysqlclient.lib(my_init.obj) : error LNK2019: 无法解析的外部符号 __imp_RegOpenKeyExA,该符号在函数 win32_have_tcpip 中被引用
mysqlclient.lib(my_init.obj) : error LNK2019: 无法解析的外部符号 __imp_putenv,该符号在函数 win_init_registry 中被引用
OLDNAMES.lib(putenv.obi) : error LNK2001: 无法解析的外部符号 __imp_putenv
mysqlclient.lib(my_init.obj) : error LNK2019: 无法解析的外部符号 __imp__tzset,该符号在函数 my_init 中被引用
mysqlclient.lib(my_time.obj) : error LNK2019: 无法解析的外部符号 __imp__localtime64_s,该符号在函数 my_init_time 中被引用
mysqlclient.lib(my_time.obj) : error LNK2019: 无法解析的外部符号 __imp__time64,该符号在函数 my_init_time 中被引用
mysqlclient.lib(asn.obj) : error LNK2001: 无法解析的外部符号 __imp__time64
mysqlclient.lib(dtoa.obj) : error LNK2019: 无法解析的外部符号 __imp___fpe_flt_rounds,该符号在函数 my_strtod_int 中被引用
mysqlclient.lib(int2str.obj) : error LNK2019: 无法解析的外部符号 __imp_ldiv,该符号在函数 int2str 中被引用
mysqlclient.lib(my_winfile.obj) : error LNK2019: 无法解析的外部符号 __imp__umask,该符号在函数 my_win_sopen 中被引用
mysqlclient.lib(my_winfile.obj) : error LNK2019: 无法解析的外部符号 __imp_fopen,该符号在函数 my_win_fopen 中被引用
mysqlclient.lib(ssl.obj) : error LNK2001: 无法解析的外部符号 __imp_fopen
mysqlclient.lib(file.obj) : error LNK2001: 无法解析的外部符号 __imp_fopen
mysqlclient.lib(my_winfile.obj) : error LNK2019: 无法解析的外部符号 __imp_fdopen,该符号在函数 my_win_fdopen 中被引用
OLDNAMES.lib(fdopen.obi) : error LNK2001: 无法解析的外部符号 __imp_fdopen
mysqlclient.lib(my_winfile.obj) : error LNK2019: 无法解析的外部符号 __imp_fileno,该符号在函数 my_win_fileno 中被引用
OLDNAMES.lib(fileno.obi) : error LNK2001: 无法解析的外部符号 __imp_fileno
mysqlclient.lib(my_winfile.obj) : error LNK2019: 无法解析的外部符号 __imp__fstat64,该符号在函数 my_win_fstat 中被引用
mysqlclient.lib(my_winfile.obj) : error LNK2019: 无法解析的外部符号 __imp__stat64,该符号在函数 my_win_stat 中被引用
mysqlclient.lib(my_mess.obj) : error LNK2019: 无法解析的外部符号 __imp_fputs,该符号在函数 my_message_stderr 中被引用
mysqlclient.lib(my_default.obj) : error LNK2001: 无法解析的外部符号 __imp_fputs
mysqlclient.lib(my_getwd.obj) : error LNK2019: 无法解析的外部符号 __imp_getcwd,该符号在函数 my_getwd 中被引用
OLDNAMES.lib(getcwd.obi) : error LNK2001: 无法解析的外部符号 __imp_getcwd
mysqlclient.lib(my_getwd.obj) : error LNK2019: 无法解析的外部符号 __imp_chdir,该符号在函数 my_setwd 中被引用
OLDNAMES.lib(chdir.obi) : error LNK2001: 无法解析的外部符号 __imp_chdir
mysqlclient.lib(my_thread.obj) : error LNK2019: 无法解析的外部符号 __imp__beginthreadex,该符号在函数 my_thread_create 中被引用
mysqlclient.lib(my_thread.obj) : error LNK2019: 无法解析的外部符号 __imp__endthreadex,该符号在函数 my_thread_exit 中被引用
mysqlclient.lib(my_lib.obj) : error LNK2019: 无法解析的外部符号 __imp__findclose,该符号在函数 my_dir 中被引用
mysqlclient.lib(my_lib.obj) : error LNK2019: 无法解析的外部符号 __imp__findfirst64i32,该符号在函数 my_dir 中被引用
mysqlclient.lib(my_lib.obj) : error LNK2019: 无法解析的外部符号 __imp__findnext64i32,该符号在函数 my_dir 中被引用
mysqlclient.lib(my_default.obj) : error LNK2019: 无法解析的外部符号 __imp_stricmp,该符号在函数 "char const * * __cdecl init_default_directories(struct st_mem_root *)" (?init_default_directories@@YAPEAPEBDPEAUst_mem_root@@@Z) 中被引用
OLDNAMES.lib(stricmp.obi) : error LNK2001: 无法解析的外部符号 __imp_stricmp
mysqlclient.lib(my_default.obj) : error LNK2019: 无法解析的外部符号 __imp_fgets,该符号在函数 "char __cdecl mysql_file_getline(char *,int,struct st_mysql_file *,char)" (?mysql_file_getline@@YADPEADHPEAUst_mysql_file@@D@Z) 中被引用
mysqlclient.lib(crypto_wrapper.obj) : error LNK2001: 无法解析的外部符号 __imp_fgets
mysqlclient.lib(my_default.obj) : error LNK2019: 无法解析的外部符号 __imp_puts,该符号在函数 my_load_defaults 中被引用
mysqlclient.lib(ssl.obj) : error LNK2019: 无法解析的外部符号 __imp_feof,该符号在函数 "int __cdecl yaSSL::read_file(class yaSSL::SSL_CTX *,char const *,int,enum yaSSL::CertType)" (?read_file@yaSSL@@YAHPEAVSSL_CTX@1@PEBDHW4CertType@1@@Z) 中被引用
mysqlclient.lib(ssl.obj) : error LNK2019: 无法解析的外部符号 __imp_fread,该符号在函数 "int __cdecl yaSSL::read_file(class yaSSL::SSL_CTX *,char const *,int,enum yaSSL::CertType)" (?read_file@yaSSL@@YAHPEAVSSL_CTX@1@PEBDHW4CertType@1@@Z) 中被引用
mysqlclient.lib(my_fstream.obj) : error LNK2001: 无法解析的外部符号 __imp_fread
mysqlclient.lib(crypto_wrapper.obj) : error LNK2001: 无法解析的外部符号 __imp_fread
mysqlclient.lib(file.obj) : error LNK2001: 无法解析的外部符号 __imp_fread
mysqlclient.lib(ssl.obj) : error LNK2019: 无法解析的外部符号 __imp_fseek,该符号在函数 "int __cdecl yaSSL::read_file(class yaSSL::SSL_CTX *,char const *,int,enum yaSSL::CertType)" (?read_file@yaSSL@@YAHPEAVSSL_CTX@1@PEBDHW4CertType@1@@Z) 中被引用
mysqlclient.lib(my_fstream.obj) : error LNK2001: 无法解析的外部符号 __imp_fseek
mysqlclient.lib(crypto_wrapper.obj) : error LNK2001: 无法解析的外部符号 __imp_fseek
mysqlclient.lib(file.obj) : error LNK2001: 无法解析的外部符号 __imp_fseek
mysqlclient.lib(ssl.obj) : error LNK2019: 无法解析的外部符号 __imp_ftell,该符号在函数 "int __cdecl yaSSL::read_file(class yaSSL::SSL_CTX *,char const *,int,enum yaSSL::CertType)" (?read_file@yaSSL@@YAHPEAVSSL_CTX@1@PEBDHW4CertType@1@@Z) 中被引用
mysqlclient.lib(my_fstream.obj) : error LNK2001: 无法解析的外部符号 __imp_ftell
mysqlclient.lib(crypto_wrapper.obj) : error LNK2001: 无法解析的外部符号 __imp_ftell
mysqlclient.lib(file.obj) : error LNK2001: 无法解析的外部符号 __imp_ftell
mysqlclient.lib(ssl.obj) : error LNK2019: 无法解析的外部符号 __imp_rewind,该符号在函数 "int __cdecl yaSSL::read_file(class yaSSL::SSL_CTX *,char const *,int,enum yaSSL::CertType)" (?read_file@yaSSL@@YAHPEAVSSL_CTX@1@PEBDHW4CertType@1@@Z) 中被引用
mysqlclient.lib(ssl.obj) : error LNK2019: 无法解析的外部符号 __imp_strncat,该符号在函数 yaSSL_CTX_load_verify_locations 中被引用
mysqlclient.lib(mf_loadpath.obj) : error LNK2001: 无法解析的外部符号 __imp_strncat
mysqlclient.lib(crypt_genhash_impl.obj) : error LNK2001: 无法解析的外部符号 __imp_strncat
mysqlclient.lib(yassl_error.obj) : error LNK2001: 无法解析的外部符号 __imp_strncpy
mysqlclient.lib(crypto_wrapper.obj) : error LNK2001: 无法解析的外部符号 __imp_strncpy
mysqlclient.lib(ssl.obj) : error LNK2001: 无法解析的外部符号 __imp_strncpy
mysqlclient.lib(viosslfactories.obj) : error LNK2001: 无法解析的外部符号 __imp_strncpy
mysqlclient.lib(yassl_int.obj) : error LNK2001: 无法解析的外部符号 __imp_strncpy
mysqlclient.lib(yassl_imp.obj) : error LNK2001: 无法解析的外部符号 __imp_strncpy
mysqlclient.lib(viosslfactories.obj) : error LNK2019: 无法解析的外部符号 __imp_strtok_s,该符号在函数 process_tls_version 中被引用
mysqlclient.lib(yassl_int.obj) : error LNK2019: 无法解析的外部符号 __imp_strstr,该符号在函数 "public: bool __cdecl yaSSL::SSL_CTX::SetCipherList(char const *)" (?SetCipherList@SSL_CTX@yaSSL@@QEAA_NPEBD@Z) 中被引用
mysqlclient.lib(crypt_genhash_impl.obj) : error LNK2001: 无法解析的外部符号 __imp_strstr
mysqlclient.lib(crypto_wrapper.obj) : error LNK2001: 无法解析的外部符号 __imp_strstr
mysqlclient.lib(my_fstream.obj) : error LNK2019: 无法解析的外部符号 __imp_ferror,该符号在函数 my_fread 中被引用
mysqlclient.lib(my_fstream.obj) : error LNK2019: 无法解析的外部符号 __imp_fwrite,该符号在函数 my_fwrite 中被引用
mysqlclient.lib(file.obj) : error LNK2001: 无法解析的外部符号 __imp_fwrite
mysqlclient.lib(crypt_genhash_impl.obj) : error LNK2019: 无法解析的外部符号 __imp_strcspn,该符号在函数 my_crypt_genhash 中被引用
mysqlclient.lib(my_fopen.obj) : error LNK2019: 无法解析的外部符号 __imp__dup2,该符号在函数 my_win_freopen 中被引用
mysqlclient.lib(my_fopen.obj) : error LNK2019: 无法解析的外部符号 __imp_freopen,该符号在函数 my_win_freopen 中被引用
mysqlclient.lib(asn.obj) : error LNK2019: 无法解析的外部符号 __imp__gmtime64,该符号在函数 "bool __cdecl TaoCrypt::`anonymous namespace'::ValidateDate(unsigned char const *,unsigned char,enum TaoCrypt::CertDecoder::DateType)" (?ValidateDate@?A0x4ae3e225@TaoCrypt@@YA_NPEBEEW4DateType@CertDecoder@2@@Z) 中被引用
mysqlclient.lib(get_password.obj) : error LNK2019: 无法解析的外部符号 __imp__cputs,该符号在函数 yassl_mysql_get_tty_password_ext 中被引用
mysqlclient.lib(get_password.obj) : error LNK2019: 无法解析的外部符号 __imp__getch,该符号在函数 yassl_mysql_get_tty_password_ext 中被引用
mysqlclient.lib(common.obj) : error LNK2019: 无法解析的外部符号 __imp_EqualSid,该符号在函数 "public: bool __cdecl Sid::operator==(class Sid const &)" (??8Sid@@QEAA_NAEBV0@@Z) 中被引用
mysqlclient.lib(common.obj) : error LNK2019: 无法解析的外部符号 __imp_GetTokenInformation,该符号在函数 "public: __cdecl Sid::Sid(void *)" (??0Sid@@QEAA@PEAX@Z) 中被引用
mysqlclient.lib(common.obj) : error LNK2019: 无法解析的外部符号 __imp_IsValidSid,该符号在函数 "public: __cdecl Sid::Sid(void *)" (??0Sid@@QEAA@PEAX@Z) 中被引用
mysqlclient.lib(common.obj) : error LNK2019: 无法解析的外部符号 __imp_LookupAccountNameW,该符号在函数 "public: __cdecl Sid::Sid(wchar_t const *)" (??0Sid@@QEAA@PEB_W@Z) 中被引用
mysqlclient.lib(random.obj) : error LNK2019: 无法解析的外部符号 __imp_CryptAcquireContextA,该符号在函数 "public: __cdecl TaoCrypt::OS_Seed::OS_Seed(void)" (??0OS_Seed@TaoCrypt@@QEAA@XZ) 中被引用
mysqlclient.lib(random.obj) : error LNK2019: 无法解析的外部符号 __imp_CryptReleaseContext,该符号在函数 "public: __cdecl TaoCrypt::OS_Seed::~OS_Seed(void)" (??1OS_Seed@TaoCrypt@@QEAA@XZ) 中被引用
mysqlclient.lib(random.obj) : error LNK2019: 无法解析的外部符号 __imp_CryptGenRandom,该符号在函数 "public: __cdecl TaoCrypt::RandomNumberGenerator::RandomNumberGenerator(void)" (??0RandomNumberGenerator@TaoCrypt@@QEAA@XZ) 中被引用
OLDNAMES.lib(strdup.obi) : error LNK2001: 无法解析的外部符号 __imp__strdup
OLDNAMES.lib(putenv.obi) : error LNK2001: 无法解析的外部符号 __imp__putenv
OLDNAMES.lib(fdopen.obi) : error LNK2001: 无法解析的外部符号 __imp__fdopen
OLDNAMES.lib(getcwd.obi) : error LNK2001: 无法解析的外部符号 __imp__getcwd
OLDNAMES.lib(chdir.obi) : error LNK2001: 无法解析的外部符号 __imp__chdir
OLDNAMES.lib(stricmp.obi) : error LNK2001: 无法解析的外部符号 __imp__stricmp
mysql.exe : fatal error LNK1120: 61 个无法解析的外部命令
-
-
Hi! Try to include to configure:
MYSQL_LIBS="-lmysqlclientMT -lAdvapi32 -lUser32 -lCrypt32 -lGdi32"
and also create a simpleMySQL
test project inVS 2017
, for example console app to verify that it works:#include <iostream> #include <mysql.h> #include <openssl/bio.h> #include <openssl/ssl.h> #include <openssl/err.h> using namespace std; int main() { cout << "Hello World!" << endl; cout << "Hello!" << endl; SSL_load_error_strings(); ERR_load_BIO_strings(); OpenSSL_add_all_algorithms(); printf("MySQL client version: %s\n", mysql_get_client_info()); system("PAUSE"); return 0; }
If you still need help, reply here or in chat and I will try to help.
-
@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.