Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt static with MySQL issue

Qt static with MySQL issue

Scheduled Pinned Locked Moved Solved General and Desktop
50 Posts 4 Posters 33.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    Can you show which configuration options you used ?

    Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by Cobra91151
    #11

    @SGaist

    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 and MySql lib path C:\MySQL\mysql-5.7.22-win32\lib but it make Qt to use C:\MySQL\mysql-5.7.22-win32\lib\libmysql.lib (dynamic). I think, should be another way to set proper library.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #12

      I would add MYSQL_LIBS=-lmysqlclient.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Cobra91151C 1 Reply Last reply
      1
      • SGaistS SGaist

        I would add MYSQL_LIBS=-lmysqlclient.

        Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by
        #13

        @SGaist

        Ok. I will try it and reply. Thanks.

        1 Reply Last reply
        0
        • Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #14

          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:

          0_1536309866313_2018-09-07_114417.png

          I think I should also provide the libmysql to MYSQL_LIBS or the problem is with mysql-5.7.23.

          1 Reply Last reply
          0
          • Cobra91151C Offline
            Cobra91151C Offline
            Cobra91151
            wrote on last edited by
            #15

            I have found the issue! Adding this line MYSQL_LIBS="-lmysqlclient" to configure for some reason breaks the detection of MySQL. I will try again to confirm it.

            1 Reply Last reply
            0
            • Cobra91151C Offline
              Cobra91151C Offline
              Cobra91151
              wrote on last edited by
              #16

              Yes, I was right. Adding MYSQL_LIBS="-lmysqlclient" breaks the detection of MySQL - 100% confirmed.

              1 Reply Last reply
              0
              • Cobra91151C Offline
                Cobra91151C Offline
                Cobra91151
                wrote on last edited by
                #17

                I run a few tests and found that Qt requires libmysql.lib to configure, but since it dynamic lib it won't work in my case. I think I should try to rename mysqlclient.lib to libmysql.lib and test it.

                1 Reply Last reply
                0
                • Cobra91151C Offline
                  Cobra91151C Offline
                  Cobra91151
                  wrote on last edited by Cobra91151
                  #18

                  No, it fails with detection the MySQL if libmysql.lib has been changed, renamed or removed.

                  1 Reply Last reply
                  0
                  • Cobra91151C Offline
                    Cobra91151C Offline
                    Cobra91151
                    wrote on last edited by
                    #19

                    I think I have found the issue.

                    0_1536347309737_2018-09-07_220816.png

                    This line of code in the file - configure.json - { "libs": "-lmysqlclient", "condition": "!config.win32" } disables mysqlclient (static) lib because condition states that !win32, means not Windows system. I will change it and try again.

                    1 Reply Last reply
                    0
                    • Cobra91151C Offline
                      Cobra91151C Offline
                      Cobra91151
                      wrote on last edited by Cobra91151
                      #20

                      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.

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        MT and MD are just related to the Windows runtime type you'll be using.

                        Cobra91151C Offline
                        Cobra91151C Offline
                        Cobra91151
                        wrote on last edited by Cobra91151
                        #21

                        @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 with MFC static test project in VS 2017.

                        alt text

                        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 with MSVCRT lib.

                        1 Reply Last reply
                        0
                        • Cobra91151C Offline
                          Cobra91151C Offline
                          Cobra91151
                          wrote on last edited by Cobra91151
                          #22

                          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 older VS versions. I need to find the MySQL source code and compile mysqlclient (static) lib for Visual Studio 2017. Any ideas where I can find it? Thanks.

                          1 Reply Last reply
                          0
                          • Cobra91151C Offline
                            Cobra91151C Offline
                            Cobra91151
                            wrote on last edited by
                            #23

                            I have found the source code here: https://dev.mysql.com/downloads/mysql/
                            Now I will read docs how to compile it.

                            1 Reply Last reply
                            0
                            • Cobra91151C Offline
                              Cobra91151C Offline
                              Cobra91151
                              wrote on last edited by Cobra91151
                              #24

                              I have built the MySQL libs, added to the MFC 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.

                              1 Reply Last reply
                              0
                              • Cobra91151C Offline
                                Cobra91151C Offline
                                Cobra91151
                                wrote on last edited by Cobra91151
                                #25

                                I have found the issue and built the MySQL libs. Then I reconfigure Qt, all built well but when I build my project I get the issue:

                                0_1536746965093_2018-09-12_130828.png

                                So, mysqlclient.lib already has the OpenSSL?

                                Also, I have the issue with debugging the app:

                                0_1536747346285_2018-09-12_131522.png

                                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 of MySQL. Any ideas? Thanks.

                                1 Reply Last reply
                                0
                                • Cobra91151C Offline
                                  Cobra91151C Offline
                                  Cobra91151
                                  wrote on last edited by
                                  #26

                                  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.

                                  1 Reply Last reply
                                  0
                                  • Cobra91151C Offline
                                    Cobra91151C Offline
                                    Cobra91151
                                    wrote on last edited by Cobra91151
                                    #27

                                    I have fixed the issue with MYSQL_LIBS_DEBUG/MYSQL_LIBS_RELEASE libs by creating the advanced batch script file. So, it compiles the debug/release separately, has a support to remove Qt source dir and unpack the source from archive using WinRaR for the next compilation.

                                    By the way, I get issue when building static Qt in the debug mode:

                                    0_1536873948680_2018-09-13_231407.png

                                    By pressing Retry it continues to build Qt successfully.

                                    Still one more issue to fix:
                                    MySQL issue

                                    1 Reply Last reply
                                    0
                                    • Cobra91151C Offline
                                      Cobra91151C Offline
                                      Cobra91151
                                      wrote on last edited by Cobra91151
                                      #28

                                      So, I have fixed the issue:

                                      alt text

                                      Solution:
                                      OpenSSL source code: 1.1.1
                                      MySQL source code: 5.7.23

                                      1. Compile static OpenSSL libs with /MDd | /MD flags for Debug/Release mode
                                      2. Compile MySQL static libs (/MDd | /MD) with pre-compiled OpenSSL 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:

                                      0_1537091492952_2018-09-16_125117.png

                                      Now I configure Qt statically with these libs (MySQL & OpenSSL), first in the Debug mode. It find MySQL and OpenSSL during configuration but then I get this issue:

                                      0_1537091590480_2018-09-16_125301.png

                                      The question is how to fix this issue with Qt? Thanks in advance.

                                      aha_1980A 1 Reply Last reply
                                      0
                                      • Cobra91151C Cobra91151

                                        So, I have fixed the issue:

                                        alt text

                                        Solution:
                                        OpenSSL source code: 1.1.1
                                        MySQL source code: 5.7.23

                                        1. Compile static OpenSSL libs with /MDd | /MD flags for Debug/Release mode
                                        2. Compile MySQL static libs (/MDd | /MD) with pre-compiled OpenSSL 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:

                                        0_1537091492952_2018-09-16_125117.png

                                        Now I configure Qt statically with these libs (MySQL & OpenSSL), first in the Debug mode. It find MySQL and OpenSSL during configuration but then I get this issue:

                                        0_1537091590480_2018-09-16_125301.png

                                        The question is how to fix this issue with Qt? Thanks in advance.

                                        aha_1980A Offline
                                        aha_1980A Offline
                                        aha_1980
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #29
                                        This post is deleted!
                                        Cobra91151C 1 Reply Last reply
                                        0
                                        • aha_1980A aha_1980

                                          This post is deleted!

                                          Cobra91151C Offline
                                          Cobra91151C Offline
                                          Cobra91151
                                          wrote on last edited by Cobra91151
                                          #30

                                          @aha_1980

                                          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?

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved