Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4

I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4

Scheduled Pinned Locked Moved Solved Mobile and Embedded
29 Posts 4 Posters 5.1k 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.
  • S Offline
    S Offline
    Surendar Dharani
    wrote on last edited by
    #1

    Hi,

    Please help me connect QT with Mysql.

    When i tries it showing following error.

    OS : Ubuntu 18.04 64 bit

    Error :

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

    QT : Using Open Source Licence.

    I am new to QT and CPP so please guide me step by step.

    Thanks in advance.

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

      Hi and welcome to devnet,

      Please take the time to search this forum for this kind of question, it has been asked many times already.

      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
        Surendar Dharani
        wrote on last edited by
        #3

        Can you please share some links for that. Because i tried there is all solutions only for windows system but i need ubuntu OS. Thanks in advance.

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

          Strange, the seconde hit of google points here.

          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
            Surendar Dharani
            wrote on last edited by
            #5

            Hi I got this when i runs ldd,

            linux-vdso.so.1 (0x00007ffe64dc3000)
            libQt5Sql.so.5 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f0594b18000)
            libQt5Core.so.5 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f05943e0000)
            libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f05941c1000)
            libmysqlclient.so.18 => not found
            libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0593e38000)
            libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0593a9a000)
            libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0593882000)
            libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0593491000)
            libicui18n.so.56 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f0592ff8000)
            libicuuc.so.56 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f0592c40000)
            libicudata.so.56 => /opt/Qt/5.9/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f059125d000)
            librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0591055000)
            libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0590e38000)
            libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0590c34000)
            libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f0590a32000)
            libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f059071b000)
            /lib64/ld-linux-x86-64.so.2 (0x00007f0594f72000)
            libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f05904a9000)

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

              Well, following the thread I pointed you to, what version of MySQL do you have on your city ?

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

              S 1 Reply Last reply
              0
              • SGaistS SGaist

                Well, following the thread I pointed you to, what version of MySQL do you have on your city ?

                S Offline
                S Offline
                Surendar Dharani
                wrote on last edited by
                #7

                @sgaist in my system mysql version is,

                mysql Ver 14.14 Distrib 5.7.27, for Linux (x86_64) using Editline wrapper

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Surendar Dharani
                  wrote on last edited by Surendar Dharani
                  #8

                  Hi,

                  Following is my response when i tried qmake please help me.

                  root@surendar:/opt/Qt/5.9/Src/qtbase/src/plugins/sqldrivers/mysql# qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
                  Project ERROR: Library 'mysql' is not defined.

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

                    So your version of MySQL is way older than the one used to build the Qt plugin.

                    Two options:

                    • like already suggested in the thread linked build the plugin against the version of MySQL you have installed.
                    • use the Qt version provided by your distribution if you don't use any API available in a newer version.

                    You should also take into account that you are using a 5 years old distribution, you should consider updating.

                    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
                      Surendar Dharani
                      wrote on last edited by
                      #10

                      @sgaist said in I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4:

                      older

                      I am updating QT 5.9 to 5.13.0

                      And i got this error when i tried qtbase configure.

                      Error:

                      root@surendar:/opt/Qt/5.9/Src/qtbase/src/plugins/sqldrivers/mysql# qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
                      Project ERROR: Library 'mysql' is not defined.

                      Once QT update finished will let you know. Thanks.

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

                        Don't build as root.

                        As for building the plugin, follow the related documentation.

                        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
                          Surendar Dharani
                          wrote on last edited by
                          #12

                          @surendar-dharani said in I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4:

                          qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro

                          I tried to qmake but it showing follwoing error again, Please help.

                          acer@surendar:/opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/mysql$ qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
                          Info: creating stash file /opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/.qmake.stash
                          Cannot read /opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory
                          Project ERROR: Library 'mysql' is not defined.

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

                            Please follow the documentation.

                            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
                              Surendar Dharani
                              wrote on last edited by Surendar Dharani
                              #14

                              Sorry for asking again and again,

                              I got this error now after i followed the document,

                              acer@surendar:/opt/Qt/5.13.0/Src/qtbase/src/plugins/sqldrivers/mysql$ make install
                              make: *** No rule to make target 'install'. Stop.

                              and when i tried ./configure -sql-mysql error is like

                              ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                Surendar Dharani
                                wrote on last edited by
                                #15

                                Please anyone help on this. Thanks a lot in advance

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

                                  Please show some patience before bumping your own thread. People answering here do it voluntarily and might not live in the same time zone as you.

                                  Did you install the MySQL development package from your distribution ?

                                  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
                                  • RonaldViscarraLR Offline
                                    RonaldViscarraLR Offline
                                    RonaldViscarraL
                                    wrote on last edited by
                                    #17

                                    Hi, in most of linux distros, there's not mysql, but mariadb, if this is the case, then you need to make a soft link to mariadb lib and call it like the mysql required

                                    S 1 Reply Last reply
                                    0
                                    • RonaldViscarraLR RonaldViscarraL

                                      Hi, in most of linux distros, there's not mysql, but mariadb, if this is the case, then you need to make a soft link to mariadb lib and call it like the mysql required

                                      S Offline
                                      S Offline
                                      Surendar Dharani
                                      wrote on last edited by
                                      #18

                                      @ronaldviscarral Hi,

                                      Thank you very much. Please tell me how to do it by step by step. Because i'm new in this. Thanks in advance.

                                      RonaldViscarraLR 1 Reply Last reply
                                      0
                                      • S Surendar Dharani

                                        @ronaldviscarral Hi,

                                        Thank you very much. Please tell me how to do it by step by step. Because i'm new in this. Thanks in advance.

                                        RonaldViscarraLR Offline
                                        RonaldViscarraLR Offline
                                        RonaldViscarraL
                                        wrote on last edited by RonaldViscarraL
                                        #19

                                        @surendar-dharani sure, first, install mariadb in your linux distro, then as super user in a terminal (for a x64 base system):

                                        ln -s /usr/lib64/libmariadb.so.3 /usr/lib64/libmysqlclient.so.18
                                        

                                        you should adapt it to your distro paths and mariadb version

                                        S 1 Reply Last reply
                                        0
                                        • RonaldViscarraLR RonaldViscarraL

                                          @surendar-dharani sure, first, install mariadb in your linux distro, then as super user in a terminal (for a x64 base system):

                                          ln -s /usr/lib64/libmariadb.so.3 /usr/lib64/libmysqlclient.so.18
                                          

                                          you should adapt it to your distro paths and mariadb version

                                          S Offline
                                          S Offline
                                          Surendar Dharani
                                          wrote on last edited by
                                          #20

                                          @ronaldviscarral said in I Can't able to connect QMYSQL Driver in QT Creator 4.9.2 and QT 5.12.4:

                                          ln -s /usr/lib64/libmariadb.so.3 /usr/lib64/libmysqlclient.so.18

                                          Hi,

                                          I have uninstalled by using following commands and installed maria DB.

                                          sudo apt-get remove --purge mysql-server mysql-client mysql-common

                                          installed mariadb by follwing command,
                                          sudo apt-get install mariadb-server

                                          And tried to compile same driver not laoded in mysql

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

                                          Now what to i do?

                                          RonaldViscarraLR 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