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
Forum Updated to NodeBB v4.3 + New Features

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 6.3k Views 1 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.
  • 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
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #21

                                    Start your application with the QT_DEBUG_PLUGINS environment variable set to 1.

                                    You'll see what is happening with your 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
                                    • RonaldViscarraLR Offline
                                      RonaldViscarraLR Offline
                                      RonaldViscarraL
                                      wrote on last edited by
                                      #22

                                      @surendar-dharani Your OS seems to have mysql, so, better install them.

                                      If you didn't compile the mysql driver, you could guide you with:
                                      https://fecub.wordpress.com/2014/08/12/compilecreate-mysql-driver-for-qt5-on-windows/

                                      When you build an app that's use mysql driver, and the plugin is compiled, and there's no mysql library availible in your system, you have the error:

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

                                      notice that QMYSQL is availible but not loaded, means that the plugin is compiled but the library was not found it.

                                      so, having been installed mysql-server and mysql-client from your package manager, find the library libmysqlclient.so.18, in a terminal you could use as super user:

                                      find / -name libmysqlclient.so.18 
                                      

                                      paste here the results to check it out

                                      S 1 Reply Last reply
                                      0
                                      • RonaldViscarraLR RonaldViscarraL

                                        @surendar-dharani Your OS seems to have mysql, so, better install them.

                                        If you didn't compile the mysql driver, you could guide you with:
                                        https://fecub.wordpress.com/2014/08/12/compilecreate-mysql-driver-for-qt5-on-windows/

                                        When you build an app that's use mysql driver, and the plugin is compiled, and there's no mysql library availible in your system, you have the error:

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

                                        notice that QMYSQL is availible but not loaded, means that the plugin is compiled but the library was not found it.

                                        so, having been installed mysql-server and mysql-client from your package manager, find the library libmysqlclient.so.18, in a terminal you could use as super user:

                                        find / -name libmysqlclient.so.18 
                                        

                                        paste here the results to check it out

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

                                        @ronaldviscarral @SGaist Hi have installed in my other system from the scratch itself, Now i got this.

                                        When i ran this sh configure -sql-mysql

                                        Output:

                                        Qt Sql Drivers:
                                        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

                                        And i tried to run QT 5.13.1

                                        And I got this ,

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

                                        And I checked in /opt/Qt/5.13.1/gcc_64/plugins/sqldrivers/

                                        But libqsqlmysql.so file is not found in this location.

                                        i think little thing is missing here. Please guide me. Thanks in advance.

                                        1 Reply Last reply
                                        0
                                        • Quang PhuQ Offline
                                          Quang PhuQ Offline
                                          Quang Phu
                                          wrote on last edited by
                                          #24

                                          Hi @Surendar-Dharani ,
                                          you have to install QMYSQL plugin first.
                                          I met this issue before and have 2 topics that you can refer
                                          https://forum.qt.io/topic/106421/qt-mac-version-doesn-t-have-file-libqsqlmysql-dylib
                                          https://forum.qt.io/topic/106565/mysql-qt-create-plugin-mysql-for-qt-on-mac

                                          S 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