Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Error while compiling Qt mySQL driver

Error while compiling Qt mySQL driver

Scheduled Pinned Locked Moved Solved C++ Gurus
24 Posts 12 Posters 21.6k 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.
  • M Offline
    M Offline
    mbnoimi
    wrote on last edited by
    #14

    Qt plugins really pain in the ass... I'm very frustrated!!!

    It seems I've to rollback to Microsoft products after years of using Qt. Because of this stupid policy of Qt I always spend hours and hours on deployment or building a stupid plugin which suppose to be available in the binary distro!!!

    Why the developer needs to rebuild anything from source code if he/she chose to use binary distro of Qt!!!

    Any way, I filed a bug report about this stupid bug in this link:
    https://bugreports.qt.io/browse/QTBUG-62078

    For whom concern:
    https://forum.qt.io/topic/81272/licenses-craziness

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Eduardo12l
      wrote on last edited by
      #15

      Have you qMake it?

      M 1 Reply Last reply
      0
      • E Eduardo12l

        Have you qMake it?

        M Offline
        M Offline
        mbnoimi
        wrote on last edited by
        #16

        @Eduardo12l Yes

        1 Reply Last reply
        0
        • D denko

          Hello guys,

          Im getting this error while trying to connect to a database in my Qt project:
          QSqlDatabase: QMYSQL driver not loaded
          QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

          libqsqlmysql.so it is located in my sqldrivers, mysql client and server are installed on my machine Im using Ubuntu 17 and Qt 5.9.

          When I tried ldd libqsqlmysql.so I get this: libmysqlclient.so.18 => not found, so I tried to compile a new one from qtbase(source code) but when I run:

          qmake "INCLUDEPATH+=MYSQL INCLUDE LOCATION" "LIBS+=-L MYSQL LIB LOCATION" mysql.pro a Makefile is created but I get this error too:

          Cannot read /home/[My Username]/Desktop/qtbase-dev/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory

          When I enter make, I get this error:
          /usr/bin/ld: cannot find /usr/lib/mysql: File format not recognized
          collect2: error: ld returned 1 exit status
          Makefile:73: recipe for target '../plugins/sqldrivers/libqsqlmysql.so' failed
          make: *** [../plugins/sqldrivers/libqsqlmysql.so] Error 1

          So this seems pretty annoying, any help is welcome :)

          M Offline
          M Offline
          Mohammad Kanan
          wrote on last edited by Mohammad Kanan
          #17

          @All, You do not really need to rebuild the plugin! I guess you may get same error even after recompile.
          Why: from the output, Qt creator, does not say there is any problem with QMYSQL, everything seems to be OK, except linking to the correct driver/lib, best to do is to try these steps first of all:

          1. download the 32-bit version of mysql connector/c from:
            libmysql 32 bit version
            on Linux/Mac we get (mysql-connector-c-6.0.2-osx10.5-x86-32bit.tar)
          2. untar, and install the package (with defaults), you should get the driver installed at :
            /usr/local/mysql-connector-c-6.0.2-osx10.5-x86-32bit/lib/libmysql.dylib
          3. Then copy it to your build folder ( <your Base Qt location>/5.9.1/clang_64/bin) ... for test -> rebuild your solution and should not show that error again, plus, database connectivity should work.
            if it works then, instead of keeping the copied library at the qt bin directory, best is to remove it and add library to your project:
          4. delete the file you copied to clang_64/bin .
          5. in your project add library pointing to the downloaded 32 bit libmysql.dll (right click -> add library -> external)
            (adding as library is suitable later for deployment).
          M 1 Reply Last reply
          3
          • M Mohammad Kanan

            @All, You do not really need to rebuild the plugin! I guess you may get same error even after recompile.
            Why: from the output, Qt creator, does not say there is any problem with QMYSQL, everything seems to be OK, except linking to the correct driver/lib, best to do is to try these steps first of all:

            1. download the 32-bit version of mysql connector/c from:
              libmysql 32 bit version
              on Linux/Mac we get (mysql-connector-c-6.0.2-osx10.5-x86-32bit.tar)
            2. untar, and install the package (with defaults), you should get the driver installed at :
              /usr/local/mysql-connector-c-6.0.2-osx10.5-x86-32bit/lib/libmysql.dylib
            3. Then copy it to your build folder ( <your Base Qt location>/5.9.1/clang_64/bin) ... for test -> rebuild your solution and should not show that error again, plus, database connectivity should work.
              if it works then, instead of keeping the copied library at the qt bin directory, best is to remove it and add library to your project:
            4. delete the file you copied to clang_64/bin .
            5. in your project add library pointing to the downloaded 32 bit libmysql.dll (right click -> add library -> external)
              (adding as library is suitable later for deployment).
            M Offline
            M Offline
            mbnoimi
            wrote on last edited by
            #18

            Thanks a lot @Mohammad-Kanan your solution worked but I used mysql-connector-c-6.1.11-linux-glibc2.12-x86_64 instead of 32 bit version

            I struggled with this issue for 15 days then I surrendered

            M 1 Reply Last reply
            0
            • M mbnoimi

              Thanks a lot @Mohammad-Kanan your solution worked but I used mysql-connector-c-6.1.11-linux-glibc2.12-x86_64 instead of 32 bit version

              I struggled with this issue for 15 days then I surrendered

              M Offline
              M Offline
              Mohammad Kanan
              wrote on last edited by
              #19

              @mbnoimi Good news! 32 or 64 bit depends on your system. I use Qt 32 bit on Win10, 64 bit, I don't know 64 bit one exists :) in my case the 64 bit lib didn't help.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                chrabaszcz.patryk
                wrote on last edited by
                #20

                Hi I had the same problem with qtsqldrivers-config.pri

                I leave it here, maybe it will be helpful

                Go to :
                /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers
                Run qmake:
                ../../../../../gcc_64/bin/qmake sqldrivers.pro
                After that I got:

                Configure summary:

                Qt Sql:
                DB2 (IBM) .............................. no
                InterBase .............................. no
                MySql .................................. yes
                OCI (Oracle) ........................... no
                ODBC ................................... no
                PostgreSQL ............................. no
                SQLite2 ................................ no
                SQLite ................................. yes
                Using system provided SQLite ......... no
                TDS (Sybase) ........................... no

                Then go to:
                /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql
                Run qmake again:
                ../../../../../../gcc_64/bin/qmake mysql.pro
                Run make:
                make
                You will see as a part of an output message that it was compiled and moved into:
                "mv -f libqsqlmysql.so ../plugins/sqldrivers/"

                Y C C 3 Replies Last reply
                1
                • C chrabaszcz.patryk

                  Hi I had the same problem with qtsqldrivers-config.pri

                  I leave it here, maybe it will be helpful

                  Go to :
                  /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers
                  Run qmake:
                  ../../../../../gcc_64/bin/qmake sqldrivers.pro
                  After that I got:

                  Configure summary:

                  Qt Sql:
                  DB2 (IBM) .............................. no
                  InterBase .............................. no
                  MySql .................................. yes
                  OCI (Oracle) ........................... no
                  ODBC ................................... no
                  PostgreSQL ............................. no
                  SQLite2 ................................ no
                  SQLite ................................. yes
                  Using system provided SQLite ......... no
                  TDS (Sybase) ........................... no

                  Then go to:
                  /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql
                  Run qmake again:
                  ../../../../../../gcc_64/bin/qmake mysql.pro
                  Run make:
                  make
                  You will see as a part of an output message that it was compiled and moved into:
                  "mv -f libqsqlmysql.so ../plugins/sqldrivers/"

                  Y Offline
                  Y Offline
                  yuzilong
                  wrote on last edited by
                  #21

                  @chrabaszcz.patryk said in Error while compiling Qt mySQL driver:

                  Hi I had the same problem with qtsqldrivers-config.pri

                  I leave it here, maybe it will be helpful

                  Go to :
                  /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers
                  Run qmake:
                  ../../../../../gcc_64/bin/qmake sqldrivers.pro
                  After that I got:

                  Configure summary:

                  Qt Sql:
                  DB2 (IBM) .............................. no
                  InterBase .............................. no
                  MySql .................................. yes
                  OCI (Oracle) ........................... no
                  ODBC ................................... no
                  PostgreSQL ............................. no
                  SQLite2 ................................ no
                  SQLite ................................. yes
                  Using system provided SQLite ......... no
                  TDS (Sybase) ........................... no

                  Then go to:
                  /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql
                  Run qmake again:
                  ../../../../../../gcc_64/bin/qmake mysql.pro
                  Run make:
                  make
                  You will see as a part of an output message that it was compiled and moved into:
                  "mv -f libqsqlmysql.so ../plugins/sqldrivers/"

                  I try to solve this problem for the whole night,your solution saved me.Solve the problem perfectly. Thanks very much.Thanks .

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    BeMind
                    wrote on last edited by
                    #22

                    @chrabaszcz-patryk

                    Hi I had the same problem with qtsqldrivers-config.pri

                    I leave it here, maybe it will be helpful

                    Go to :
                    /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers
                    Run qmake:
                    ../../../../../gcc_64/bin/qmake sqldrivers.pro
                    After that I got:

                    Configure summary:

                    Qt Sql:
                    DB2 (IBM) .............................. no
                    InterBase .............................. no
                    MySql .................................. yes
                    OCI (Oracle) ........................... no
                    ODBC ................................... no
                    PostgreSQL ............................. no
                    SQLite2 ................................ no
                    SQLite ................................. yes
                    Using system provided SQLite ......... no
                    TDS (Sybase) ........................... no

                    Then go to:
                    /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql
                    Run qmake again:
                    ../../../../../../gcc_64/bin/qmake mysql.pro
                    Run make:
                    make
                    You will see as a part of an output message that it was compiled and moved into:
                    "mv -f libqsqlmysql.so ../plugins/sqldrivers/"

                    I had this problem when added Qt 5.13.0 using online installation to the Qt 5.12 i have already installed i thought the installation was wrong until i came across your solution. Thanks you very much.

                    1 Reply Last reply
                    0
                    • C chrabaszcz.patryk

                      Hi I had the same problem with qtsqldrivers-config.pri

                      I leave it here, maybe it will be helpful

                      Go to :
                      /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers
                      Run qmake:
                      ../../../../../gcc_64/bin/qmake sqldrivers.pro
                      After that I got:

                      Configure summary:

                      Qt Sql:
                      DB2 (IBM) .............................. no
                      InterBase .............................. no
                      MySql .................................. yes
                      OCI (Oracle) ........................... no
                      ODBC ................................... no
                      PostgreSQL ............................. no
                      SQLite2 ................................ no
                      SQLite ................................. yes
                      Using system provided SQLite ......... no
                      TDS (Sybase) ........................... no

                      Then go to:
                      /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql
                      Run qmake again:
                      ../../../../../../gcc_64/bin/qmake mysql.pro
                      Run make:
                      make
                      You will see as a part of an output message that it was compiled and moved into:
                      "mv -f libqsqlmysql.so ../plugins/sqldrivers/"

                      C Offline
                      C Offline
                      Cocojambo
                      wrote on last edited by
                      #23

                      @chrabaszcz-patryk Registered here to thank you for your useful message :)

                      This problem is still actual in 5.15.0. Solved it as you mentioned.

                      1 Reply Last reply
                      0
                      • C chrabaszcz.patryk

                        Hi I had the same problem with qtsqldrivers-config.pri

                        I leave it here, maybe it will be helpful

                        Go to :
                        /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers
                        Run qmake:
                        ../../../../../gcc_64/bin/qmake sqldrivers.pro
                        After that I got:

                        Configure summary:

                        Qt Sql:
                        DB2 (IBM) .............................. no
                        InterBase .............................. no
                        MySql .................................. yes
                        OCI (Oracle) ........................... no
                        ODBC ................................... no
                        PostgreSQL ............................. no
                        SQLite2 ................................ no
                        SQLite ................................. yes
                        Using system provided SQLite ......... no
                        TDS (Sybase) ........................... no

                        Then go to:
                        /Qt_new/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql
                        Run qmake again:
                        ../../../../../../gcc_64/bin/qmake mysql.pro
                        Run make:
                        make
                        You will see as a part of an output message that it was compiled and moved into:
                        "mv -f libqsqlmysql.so ../plugins/sqldrivers/"

                        C Offline
                        C Offline
                        caha11
                        wrote on last edited by
                        #24

                        @chrabaszcz-patryk Confirming this works, was trying to install ODBC and had the same error as OP. Did the suggested steps by @chrabaszcz-patryk and it worked on Qt 5.11.3 on Rpi 4B.

                        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