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. QMYSQL driver not loaded, but source file not found to rebuild

QMYSQL driver not loaded, but source file not found to rebuild

Scheduled Pinned Locked Moved General and Desktop
ubuntumysql
17 Posts 3 Posters 6.2k 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.
  • R Offline
    R Offline
    rhonaldjr
    wrote on 4 Dec 2016, 16:56 last edited by A Former User
    #1

    Hi,

    I have the age old issue, but surprisingly I haven't found much solution (I am new to GNU/Linux development and Qt). So when I run a program to use MySQL,

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

    it throws the age-old, much-referred error message:

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

    I found the below files at the Qt plugins directory.

    libqsqlite.so libqsqlmysql.so libqsqlpsql.so

    When I did ldd, the below is the line that's of issue:

    libmysqlclient_r.so.16 => not found

    I have libqt5sql5-mysql and it's version 20.

    Tried

    • I tried tricking the program by creating symbolic link as libmysqlclient_r.so.16 but it does't work

    • list itemCopy the libqsqlmysql.so file from the /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so to the Qt plugins folder and run (got the error: Cannot mix incompatible Qt library (version 0x50601) with this library (version 0x50700))
      Ran maint

    • list itemenance tool, added the repository manually, but found no source packages
      Re-Instal

    • list itemled Qt and this time selected the source package and installed, but no source for mysqldrivers found to compile

    I am stuck for 2 weeks with no help. I will have to either fix this issue dump Qt and look into Gtk or Mono.

    Ubuntu: 16.10
    Qt Versions: Qt Creator 4.0.2, Qt: 5.7.0

    Please help.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rhonaldjr
      wrote on 4 Dec 2016, 17:13 last edited by
      #2

      Have tried all these links & forums:

      https://forum.qt.io/topic/73732/qt-mysql-support
      https://forum.qt.io/topic/73577/qt5-8-0-mysql-driver-not-found
      https://forum.qt.io/topic/69280/integration-mysql-and-qt5-7/10

      Look like most of the newbies gave up after a bit of try

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 4 Dec 2016, 21:54 last edited by
        #3

        Hi and welcome to devnet,

        2 solutions:

        1. Use your distribution provided Qt
        2. Build the plugin yourself.

        For 2:

        1. Download the Qt sources through e.g. the Maintenance tool
        2. Install the MySQL dev package for your distribution
        3. Follow the documentation on how to build the plugin
        4. Don't forget to call make install once built.

        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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Dec 2016, 21:56 last edited by
          #4

          By the way, the plugin sources are in qtbase.

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

          R 1 Reply Last reply 5 Dec 2016, 01:39
          0
          • S SGaist
            4 Dec 2016, 21:56

            By the way, the plugin sources are in qtbase.

            R Offline
            R Offline
            rhonaldjr
            wrote on 5 Dec 2016, 01:39 last edited by
            #5

            @SGaist thanks, worked, but found another error saying that the Qt5 Kit is not a valid one. After a bit of searching, I had to install "qt5-default" to resolve this.

            Thanks a lot.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 5 Dec 2016, 10:33 last edited by
              #6

              How did you setup Qt ?

              Looks like you are mixing the one from your distribution and the one from the official installer.

              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
              • W Offline
                W Offline
                walter-j
                wrote on 15 Dec 2016, 22:04 last edited by
                #7

                I have the same problem. i got the error MYSQdriver not loaded and i have followed all suggestions in forums but the issue is not fixed. can someone help me please?

                thanks,

                JK

                Josephat Kabitshwa

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 15 Dec 2016, 22:10 last edited by
                  #8

                  Hi and welcome to devnet,

                  What exactly don't work ?
                  What error are you getting ?
                  Did you follow the step by step guide I wrote earlier ?
                  If so, did one of the point fail at any time ?
                  What version of Qt are you using ?
                  On what OS ?
                  With what compiler ?

                  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
                  • W Offline
                    W Offline
                    walter-j
                    wrote on 15 Dec 2016, 22:18 last edited by
                    #9

                    im using linux mint 18. Qt version 5.1.1. i received this error: mysql driver not loaded. yes i have try all these suggestions but i don't know how to begin since im new in linux

                    Josephat Kabitshwa

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      walter-j
                      wrote on 15 Dec 2016, 22:24 last edited by
                      #10

                      ldd /home/walter-j/Qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so
                      linux-vdso.so.1 => (0x00007ffedfdda000)
                      libmysqlclient_r.so.16 => /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.16 (0x00007f949e3a8000)
                      libQt5Sql.so.5 => /home/walter-j/Qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/../../lib/libQt5Sql.so.5 (0x00007f949e169000)
                      libQt5Core.so.5 => /home/walter-j/Qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/../../lib/libQt5Core.so.5 (0x00007f949dade000)
                      libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f949d75c000)
                      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f949d393000)
                      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f949d175000)
                      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f949ce6c000)
                      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f949cc52000)
                      libicui18n.so.51 => /home/walter-j/Qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/../../lib/libicui18n.so.51 (0x00007f949c838000)
                      libicuuc.so.51 => /home/walter-j/Qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/../../lib/libicuuc.so.51 (0x00007f949c4b2000)
                      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f949c2ae000)
                      libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f949c0ab000)
                      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f949bea3000)
                      libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f949bb92000)
                      libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f949b97b000)
                      /lib64/ld-linux-x86-64.so.2 (0x000055c820f7a000)
                      libicudata.so.51 => /home/walter-j/Qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/../../lib/libicudata.so.51 (0x00007f949a232000)
                      libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f9499fc1000)

                      Josephat Kabitshwa

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 15 Dec 2016, 22:25 last edited by
                        #11

                        Did you also print the exact error you got ?

                        The plugin looks fine.

                        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
                        • W Offline
                          W Offline
                          walter-j
                          wrote on 15 Dec 2016, 22:29 last edited by
                          #12

                          0_1481840852645_upload-a114047b-129c-4c7a-b22d-5f25d662ab65

                          #include <QCoreApplication>

                          #include <QtSql/QSql>
                          #include <QtSql/QSqlDatabase>
                          #include <QtSql/QSqlDriver>
                          #include <QtSql/QSqlQuery>
                          #include <QDebug>

                          bool createConnection();

                          int main(int argc, char *argv[])
                          {
                          QCoreApplication a(argc, argv);
                          if (!createConnection()){
                          qDebug() << "Not connected!";
                          return 1;
                          }
                          else{
                          qDebug() << "Connected";
                          QSqlQuery query;
                          query.exec("SELECT name FROM student");

                              while (query.next()) {
                                  QString name = query.value(0).toString();
                                  qDebug() << "name:" << name;
                              }
                              return 0;
                          }
                          
                          return a.exec();
                          

                          }

                          bool createConnection() {

                          // QApplication::addLibraryPath("/home/walter-j/Qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers");
                          QSqlDatabase db = QSqlDatabase::addDatabase("QSLITE");
                          db.setHostName("localhost");
                          db.setDatabaseName("test.db");
                          db.setUserName("root");
                          db.setPassword("");
                          // db.setPort(3306);
                          // QSqlDriver *driver = QSqlDatabase::database().driver();
                          if(!db.open()){
                          qDebug() << "Database error occurred";
                          return false;
                          }

                          return true;
                          

                          }

                          #-------------------------------------------------

                          Project created by QtCreator 2016-12-15T19:04:16

                          #-------------------------------------------------

                          QT += core sql

                          QT -= gui

                          TARGET = test
                          CONFIG += console
                          CONFIG -= app_bundle

                          TEMPLATE = app

                          SOURCES += main.cpp

                          Josephat Kabitshwa

                          1 Reply Last reply
                          0
                          • W Offline
                            W Offline
                            walter-j
                            wrote on 15 Dec 2016, 22:39 last edited by
                            #13

                            the plugin looks fine but im still getting a error. i don'tknow exactly what wrong

                            Josephat Kabitshwa

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 15 Dec 2016, 22:41 last edited by
                              #14

                              You are not use the MySQL driver and you are using the wrong name for the SQLite driver. It's QSQLITE .

                              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
                              • W Offline
                                W Offline
                                walter-j
                                wrote on 15 Dec 2016, 22:44 last edited by
                                #15

                                i tried mysql, sqlite, postgres i m having the same error

                                Josephat Kabitshwa

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 15 Dec 2016, 22:52 last edited by
                                  #16

                                  Print the text returned by db.lastError()

                                  Just saying that it doesn't work with the "Driver not loaded" message doesn't help much.

                                  Based on your current code, it's not really surprising:

                                  1. You gave the driver name wrong.
                                  2. You are mixing the setup for the sqlite driver with the setup for a server based database.

                                  One other important detail: do you have any of the SQL server running on your machine to connect to ? Is it properly configured ?

                                  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
                                  • W Offline
                                    W Offline
                                    walter-j
                                    wrote on 15 Dec 2016, 22:55 last edited by
                                    #17

                                    Thank you dear friend .

                                    You're right . the drivers names were wrong . it works now

                                    Josephat Kabitshwa

                                    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