Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Cannot compile MySql driver under Windows
QtWS25 Last Chance

Cannot compile MySql driver under Windows

Scheduled Pinned Locked Moved Solved Installation and Deployment
9 Posts 3 Posters 1.4k Views
  • 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.
  • H Offline
    H Offline
    Higestromm
    wrote on last edited by
    #1

    Hi,

    I need help with mysql driver compilation.

    I've downloaded Qt 5.13 for windows (x64).
    I've downloaded Mysql Connector and then i tried to compile drivers as describe here https://doc.qt.io/qt-5/sql-driver.html

    when running the command line :
    qmake.exe -- MYSQL_INCDIR=%MYSQLDIR%/include MYSQL_LIBDIR="%MYSQLDIR%/lib/opt"

    i got the following error :
    Project ERROR: Library 'mysql' is not defined.

    Somewhere i read that I must run qmake from the folder plugins\sqldrivers.
    When i do this i got the following result :

    C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake.exe
    
    Running configuration tests...
    Done running configuration tests.
    
    Configure summary:
    
    Qt Sql Drivers:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. no
      OCI (Oracle) ........................... no
      ODBC ................................... no
      PostgreSQL ............................. no
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    
    Qt is now configured for building. Just run 'nmake'.
    Once everything is built, you must run 'nmake install'.
    Qt will be installed into 'C:\Qt\Qt5.13.2\5.13.2\msvc2015_64'.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

    I see that mysql is not recognized. Anyone got an idea to put it to yes ?

    Thank you :)

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Higestromm
      wrote on last edited by
      #2

      Some news.

      Ive edited the mysql.pro file and comment the line :
      #QMAKE_USE += mysql

      then i change my script as follow :

      @echo off
      set QTDIR=C:\Qt\Qt5.13.2\5.13.2\msvc2015_64
      set MYSQCONNECTOR=C:\c++\extlibs-src\Mysql\x64
      set MYSQCONNECTORLIB=%MYSQCONNECTOR%\lib\vs14
      set MYSQCONNECTORINC=%MYSQCONNECTOR%\include
      set VCDIR=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
      set PATH=%VCDIR%;%QTDIR%\bin;%PATH%
      
      @echo on
      cd %QTDIR%\..\Src\qtbase\src\plugins\sqldrivers\mysql
      qmake CONFIG+=x86_64 INCLUDEPATH+="%MYSQCONNECTORINC%" LIBS="%MYSQCONNECTORLIB%\mysqlclient.lib"
      nmake
      @echo off
      cd "c:\c++"
      

      The compilation seems to work well until the linking step. Now I got this error message :

      Qt5Sql.lib(Qt5Sql.dll) : fatal error LNK1112: type d'ordinateur module 'x64' en conflit avec le type d'ordinateur cible 'X86'
      

      It seems that the compiler is trying to make a x86 library with x64 ones. Now i want to force the compilation to be in x64.
      Anyone know how to do ?

      Thank you

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

        Hi and welcome to devnet,

        You should activate the correct environment using Visual Studio's vcvars script.

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

        C 1 Reply Last reply
        1
        • H Offline
          H Offline
          Higestromm
          wrote on last edited by
          #4

          Thank you for your answer.

          I tried to add this line to my batch file before calling qmake :
          call vcvarsall.bat x64

          And I still got the same error :/

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Higestromm
            wrote on last edited by
            #5

            I also tried to launch my script from the "Visual Studio command Prompt x64" and I still got the same error.

            do a sort of "make clean" before trying to recompile but I don't know how to do :/

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Higestromm
              wrote on last edited by
              #6

              Ok here is my new script executed from a x64 Visual studio command Prompt :

              @echo off
              set QTDIR=C:\Qt\Qt5.13.2\5.13.2\msvc2015_64
              set MYSQCONNECTOR=C:\c++\extlibs-src\Mysql\x64
              set MYSQCONNECTORLIB=%MYSQCONNECTOR%\lib\vs14
              set MYSQCONNECTORINC=%MYSQCONNECTOR%\include
              set PATH=%QTDIR%\bin;%PATH%
              
              @echo on
              cd %QTDIR%\..\Src\qtbase\src\plugins\sqldrivers\mysql
              qmake CONFIG+=x86_64 INCLUDEPATH+="%MYSQCONNECTORINC%" LIBS="%MYSQCONNECTORLIB%\mysqlclient.lib"
              nmake /f Makefile clean
              nmake
              

              And now I got a link error :

              mysqlclient.lib(my_init.obj) : error LNK2019: symbole externe non résolu __imp_RegCloseKey référencé dans la fonction win32_have_tcpip
              mysqlclient.lib(my_init.obj) : error LNK2019: symbole externe non résolu __imp_RegEnumValueA référencé dans la fonction win_init_registry
              mysqlclient.lib(my_init.obj) : error LNK2019: symbole externe non résolu __imp_RegOpenKeyExA référencé dans la fonction win32_have_tcpip
              mysqlclient.lib(common.obj) : error LNK2019: symbole externe non résolu __imp_EqualSid référencé dans la fonction "public: bool __cdecl Sid::operator==(class Sid const &)" (??8Sid@@QEAA_NAEBV0@@Z)
              mysqlclient.lib(common.obj) : error LNK2019: symbole externe non résolu __imp_GetTokenInformation référencé dans la fonction "public: __cdecl Sid::Sid(void *)" (??0Sid@@QEAA@PEAX@Z)
              mysqlclient.lib(common.obj) : error LNK2019: symbole externe non résolu __imp_IsValidSid référencé dans la fonction "public: __cdecl Sid::Sid(void *)" (??0Sid@@QEAA@PEAX@Z)
              mysqlclient.lib(common.obj) : error LNK2019: symbole externe non résolu __imp_LookupAccountNameW référencé dans la fonction "public: __cdecl Sid::Sid(wchar_t const *)" (??0Sid@@QEAA@PEB_W@Z)
              mysqlclient.lib(random.obj) : error LNK2019: symbole externe non résolu __imp_CryptAcquireContextA référencé dans la fonction "public: __cdecl TaoCrypt::OS_Seed::OS_Seed(void)" (??0OS_Seed@TaoCrypt@@QEAA@XZ)
              mysqlclient.lib(random.obj) : error LNK2019: symbole externe non résolu __imp_CryptReleaseContext référencé dans la fonction "public: __cdecl TaoCrypt::OS_Seed::~OS_Seed(void)" (??1OS_Seed@TaoCrypt@@QEAA@XZ)
              mysqlclient.lib(random.obj) : error LNK2019: symbole externe non résolu __imp_CryptGenRandom référencé dans la fonction "public: __cdecl TaoCrypt::RandomNumberGenerator::RandomNumberGenerator(void)" (??0RandomNumberGenerator@TaoCrypt@@QEAA@XZ)
              

              Maybe ond day it will work :/

              1 Reply Last reply
              0
              • H Offline
                H Offline
                Higestromm
                wrote on last edited by
                #7

                Ok my bad. I was linking the mad library (the static version) instead of the shared version :) now it's work :) thank you

                C 1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi and welcome to devnet,

                  You should activate the correct environment using Visual Studio's vcvars script.

                  C Offline
                  C Offline
                  cawlfj
                  wrote on last edited by
                  #8

                  @SGaist
                  qt with mysql build is a very bad experience .
                  Many peoples can't get success on build qt with mysql ,but there is no a instruction step by step long time.

                  1 Reply Last reply
                  0
                  • H Higestromm

                    Ok my bad. I was linking the mad library (the static version) instead of the shared version :) now it's work :) thank you

                    C Offline
                    C Offline
                    cawlfj
                    wrote on last edited by
                    #9

                    @Higestromm
                    Cloud you share which link for download Mysql Connector c++?
                    When build a static qt with mysql , the Mysql Connector c++ is a big problem .
                    Seems mysqlclient.lib is complied by MinGW,if use build a static qt by VS and include mysqlclient.lib(build by MinGW) will get failure.
                    Did you try build a static with mysql by VS?

                    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