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. QMYSQL driver not loaded on Ubuntu
Forum Updated to NodeBB v4.3 + New Features

QMYSQL driver not loaded on Ubuntu

Scheduled Pinned Locked Moved Solved Installation and Deployment
61 Posts 5 Posters 80.5k Views 2 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    Hello everybody i get and installed Qt 5.2 x64 edition for Linux ubuntu.

    I have QTPLUGIN += qsqlmysql and QT += sql in file .pro

    and libqsqlmysql.so plugin is in /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers folder but after run show me errors...

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QSQLITE2 QPSQL7 QPSQL

    why ? how I can fix this error?

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

      Hi,

      Do you also have the MySql libraries installed on your OS ?

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Yes !

        root@Gigabyte-Z68P-DS3:~# dpkg --list|grep mysql
        ii libmysql++-dev 3.1.0-2 amd64 MySQL C++ library bindings (development)
        ii libmysql++3 3.1.0-2 amd64 MySQL C++ library bindings (runtime)
        ii libmysqlclient-dev 5.5.34-0ubuntu0.13.10.1 amd64 MySQL database development files
        ii libmysqlclient18:amd64 5.5.34-0ubuntu0.13.10.1 amd64 MySQL database client library
        ii libmysqlclient18:i386 5.5.34-0ubuntu0.13.10.1 i386 MySQL database client library
        ii libmysqlcppconn-dev 1.1.3-3 amd64 MySQL Connector for C++ (development files)
        ii libmysqlcppconn7 1.1.3-3 amd64 MySQL Connector for C++ (library)
        ii libqt4-sql-mysql:amd64 4:4.8.4+dfsg-0ubuntu18.1 amd64 Qt 4 MySQL database driver
        ii libqt4-sql-mysql:i386 4:4.8.4+dfsg-0ubuntu18.1 i386 Qt 4 MySQL database driver
        ii libqt5sql5-mysql:amd64 5.0.2+dfsg1-7ubuntu11.1 amd64 Qt 5 MySQL database driver
        ii mysql-common 5.5.34-0ubuntu0.13.10.1 all MySQL database common files, e.g. /etc/mysql/my.cnf

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

          And what do you get if your run ldd on Qt's mysql plugin ?

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

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            I don't understand ! I,m new on Qt ...
            Of course I use XAMPP for testing MySQL Database.

            my code for test on console app :

            @
            #include <QCoreApplication>
            #include <QtSql/QSqlDatabase>
            #include <QtSql>
            #include <QDebug>

            //remplacer l'affichage par la commande cout
            #define q2c(string) string.toStdString()

            int main(int argc, char *argv[])
            {
            QCoreApplication a(argc, argv);

            QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); // This is the line I got error
               db.setHostName("localhost");
               db.setDatabaseName("qtdatabase");
               db.setUserName("root");
               db.setPassword("");
               bool ok = db.open();
            
            return a.exec&#40;&#41;;
            

            }

            @

            return this errors :

            QSqlDatabase: QMYSQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QSQLITE2 QMYSQL QMYSQL3 QPSQL7 QPSQL

            but with this code :

            @
            #include <QCoreApplication>
            #include <QtSql/qsql.h>
            #include <QtSql/qsqldatabase.h>
            #include <QtSql/QSqlError>
            #include <QtSql/QSqlQuery>
            #include <QDebug>

            int main(int argc, char *argv[])
            {
            QCoreApplication a(argc, argv);

            QStringList drivers = QSqlDatabase::drivers();
                for(int i = 0; i < drivers.count(); i++)
                    qDebug() << drivers.at(i);
            
            return a.exec(&#41;;
            

            }

            @

            return this output:

            "QMYSQL","QMYSQL3" and ...

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

              Qt's MySql plugin is call libqsqlmysql.so, call ldd on it and check that it can find all dependencies

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

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                [quote author="SGaist" date="1388524196"]Qt's MySql plugin is call libqsqlmysql.so, call ldd on it and check that it can find all dependencies[/quote]

                what is your mean of ldd ? I have libqsqlmysql.so file in below address :

                /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers

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

                  ldd is a little utility that lists the dependencies of an executable/dynamic library

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

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    [quote author="SGaist" date="1388526680"]ldd is a little utility that lists the dependencies of an executable/dynamic library[/quote]

                    How can I check this option ? This is installed utility on OS or Qt ?
                    Please give me more information about this.
                    How to call ldd?

                    I now install Qt on Windows for check my problem but now show error for load..

                    Qt_5_2_0_MinGW_32bit edition:

                    Starting C:\Users\Kambiz\Documents\Qt\build-untitled16-Desktop_Qt_5_2_0_MinGW_32bit-Debug\debug\untitled16.exe...
                    QSqlDatabase: QMYSQL driver not loaded
                    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                    C:\Users\Kambiz\Documents\Qt\build-untitled16-Desktop_Qt_5_2_0_MinGW_32bit-Debug\debug\untitled16.exe exited with code 0

                    Qt_5_2_0_MSVC2012_64bit edition:
                    Starting C:\Users\Kambiz\Documents\Qt\build-untitled15-Desktop_Qt_5_2_0_MSVC2012_64bit-Debug\debug\untitled15.exe...
                    QSqlDatabase: QMYSQL driver not loaded

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

                      "here":http://bit.ly/1l2bNYY

                      Did you install MySQL on Windows ? Do you have the MySql dll somewhere accessible in your PATH ?

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

                      1 Reply Last reply
                      0
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #11

                        [quote author="SGaist" date="1388613736"]"here":http://bit.ly/1l2bNYY

                        Did you install MySQL on Windows ? Do you have the MySql dll somewhere accessible in your PATH ?[/quote]

                        Yes I have it on below path :

                        C:\Program Files\MySQL\MySQL Server 5.6
                        and
                        C:\Program Files (X86) \MySQL\MySQL Server 5.6

                        and on Linux ubuntu too

                        On Windows I use of qt-windows-opensource-5.2.0-mingw48_opengl-x86-offline.exe and qt-windows-opensource-5.2.0-msvc2012-x86_64-offline.exe

                        but I don't know why doesn't work :(

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

                          You didn't answer the questions:
                          What does ldd return ?

                          Is the MySql dll folder in your PATH variable ? Or at least in the PATH environment variable in the run section of the Project panel in Qt Creator ?

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

                          1 Reply Last reply
                          0
                          • ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #13

                            For Windows...

                            MySql dll folder :
                            I have libmysql.dll and libmysql.lib and mysqlclient.lib here C:\Program Files\MySQL\MySQL Server 5.6\lib

                            and I have qsqlmysql.dll and qsqlmysqld.dll and other files in here :

                            C:\Qt\Qt5.2.0-MG\5.2.0\mingw48_32\plugins\sqldrivers
                            and
                            C:\Qt\Qt5.2.0\5.2.0\msvc2012_64\plugins\sqldrivers

                            1 Reply Last reply
                            0
                            • ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #14

                              and For Linux about ldd :

                              root@Gigabyte-Z68P-DS3:~# ldd /bin/date
                              linux-vdso.so.1 => (0x00007fff31d72000)
                              librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0ea438c000)
                              libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ea3fc4000)
                              libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0ea3da6000)
                              /lib64/ld-linux-x86-64.so.2 (0x00007f0ea45b5000)

                              and about MySQL plugin folder and files:

                              in here :

                              /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers .... I have libqsqlmysql.so

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

                                I know where your dlls are. If using 64bit, the question is: is "C:\Program Files\MySQL\MySQL Server 5.6\lib" contained in the PATH environment variable in the Run section on the Project panel in Qt Creator ?

                                I didn't ask you to run ldd on /bin/date but on your Qt 5.2.0 libqsqlmysql.so

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

                                1 Reply Last reply
                                0
                                • ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on last edited by
                                  #16

                                  [quote author="SGaist" date="1388785738"]I know where your dlls are. If using 64bit, the question is: is "C:\Program Files\MySQL\MySQL Server 5.6\lib" contained in the PATH environment variable in the Run section on the Project panel in Qt Creator ?
                                  [/quote]

                                  OMG! NO...
                                  Sorry ! I forget PATH environment variable !!! now my problem is sloved on Windows by add PATH environment variable for Mysql :)

                                  but for linux ?! can you give me more information ?

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

                                    You already have all the information: call "ldd /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so"

                                    to see what libraries it links to

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

                                    1 Reply Last reply
                                    0
                                    • ? Offline
                                      ? Offline
                                      A Former User
                                      wrote on last edited by
                                      #18

                                      [quote author="SGaist" date="1388788157"]You already have all the information: call "ldd /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so"

                                      to see what libraries it links to[/quote]

                                      This is :

                                      root@Gigabyte-Z68P-DS3:~# ldd /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so
                                      linux-vdso.so.1 => (0x00007fff2c89b000)
                                      libmysqlclient_r.so.16 => not found
                                      libQt5Sql.so.5 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libQt5Sql.so.5 (0x00007f23cac7a000)
                                      libQt5Core.so.5 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libQt5Core.so.5 (0x00007f23ca5ac000)
                                      libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f23ca2a8000)
                                      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f23c9ee0000)
                                      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f23c9cc2000)
                                      libicui18n.so.51 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libicui18n.so.51 (0x00007f23c98a9000)
                                      libicuuc.so.51 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libicuuc.so.51 (0x00007f23c9523000)
                                      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f23c931e000)
                                      libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f23c911c000)
                                      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f23c8f14000)
                                      libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f23c8c12000)
                                      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f23c890e000)
                                      libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f23c86f8000)
                                      /lib64/ld-linux-x86-64.so.2 (0x00007f23cb0ec000)
                                      libicudata.so.51 => /opt/Qt5.2.0/5.2.0/gcc_64/plugins/sqldrivers/../../lib/libicudata.so.51 (0x00007f23c6fae000)
                                      libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f23c6d6f000)
                                      root@Gigabyte-Z68P-DS3:~#

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

                                        You have it on the second line:

                                        @libmysqlclient_r.so.16 => not found@

                                        Check what version number of libmysqlclient_r you have installed

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

                                        1 Reply Last reply
                                        0
                                        • ? Offline
                                          ? Offline
                                          A Former User
                                          wrote on last edited by
                                          #20

                                          [quote author="SGaist" date="1388870467"]You have it on the second line:

                                          @libmysqlclient_r.so.16 => not found@

                                          Check what version number of libmysqlclient_r you have installed[/quote]

                                          root@Gigabyte-Z68P-DS3:~# dpkg --get-selections | grep mysql
                                          libmysql++-dev install
                                          libmysql++3 install
                                          libmysqlclient-dev install
                                          libmysqlclient18:amd64 install
                                          libmysqlclient18:i386 install
                                          libmysqlcppconn-dev install
                                          libmysqlcppconn7 install
                                          libqt4-sql-mysql:amd64 install
                                          libqt4-sql-mysql:i386 install
                                          libqt5sql5-mysql:amd64 install
                                          mysql-client-core-5.5 install
                                          mysql-common install
                                          root@Gigabyte-Z68P-DS3:~#

                                          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