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
QtWS25 Last Chance

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.
  • 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
                    • Quang PhuQ Quang Phu

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

                      @quang-phu @SGaist @RonaldViscarraL

                      when i run this /opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers# make sub-mysql

                      I got this :
                      cd mysql/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro MYSQL_PREFIX=/usr/local ) && make -f Makefile
                      make[1]: Entering directory '/opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers/mysql'
                      g++ -c -g -O2 -fdebug-prefix-map=/build/qtbase-opensource-src-5DihdB/qtbase-opensource-src-5.9.5+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -D_REENTRANT -fPIC -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.9.5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.9.5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.9.5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.9.5/QtCore -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -isystem /usr/include/mysql -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp
                      In file included from /usr/include/x86_64-linux-gnu/qt5/QtSql/qtsqlglobal.h:43:0,
                      from /usr/include/x86_64-linux-gnu/qt5/QtSql/qsqldriver.h:43,
                      from qsql_mysql_p.h:54,
                      from qsql_mysql.cpp:40:
                      qsql_mysql.cpp:1469:5: error: division by zero in #if
                      #if QT_CONFIG(thread)
                      ^
                      qsql_mysql.cpp:1483:5: error: division by zero in #if
                      #if QT_CONFIG(thread)
                      ^
                      qsql_mysql.cpp: In function ‘QSqlField qToField(MYSQL_FIELD
                      , QTextCodec
                      )’:
                      qsql_mysql.cpp:344:44: error: no matching function for call to ‘QSqlField::QSqlField(QString, QVariant::Type, QString)’
                      toUnicode(tc, field->table));
                      ^
                      In file included from qsql_mysql.cpp:46:0:
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:60:5: note: candidate: QSqlField::QSqlField(const QSqlField&)
                      QSqlField(const QSqlField& other);
                      ^~~~~~~~~
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:60:5: note: candidate expects 1 argument, 3 provided
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:57:14: note: candidate: QSqlField::QSqlField(const QString&, QVariant::Type)
                      explicit QSqlField(const QString& fieldName = QString(),
                      ^~~~~~~~~
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/qsqlfield.h:57:14: note: candidate expects 2 arguments, 3 provided
                      Makefile:376: recipe for target '.obj/qsql_mysql.o' failed
                      make[1]: [.obj/qsql_mysql.o] Error 1
                      make[1]: Leaving directory '/opt/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers/mysql'
                      Makefile:42: recipe for target 'sub-mysql' failed
                      make: [sub-mysql] Error 2**

                      and when i ran sh configure in qtbase folder i got this,

                      g++: error: /opt/Qt/5.13.1/Src/qtbase/lib/libqtpcre2.a: No such file or directory
                      Makefile:1214: recipe for target '../../lib/libQt5Core.so.5.13.1' failed
                      make[2]: *** [../../lib/libQt5Core.so.5.13.1] Error 1
                      make[2]: Leaving directory '/opt/Qt/5.13.1/Src/qtbase/src/corelib'
                      Makefile:213: recipe for target 'sub-corelib-install_subtargets' failed
                      make[1]: *** [sub-corelib-install_subtargets] Error 2
                      make[1]: Leaving directory '/opt/Qt/5.13.1/Src/qtbase/src'
                      Makefile:62: recipe for target 'sub-src-install_subtargets' failed
                      make: *** [sub-src-install_subtargets] Error 2

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

                        From the looks of it, you are mixing several versions of Qt.
                        There's references to both Qt 5.13 and Qt 5.9.5 which is not a good sign.

                        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

                          From the looks of it, you are mixing several versions of Qt.
                          There's references to both Qt 5.13 and Qt 5.9.5 which is not a good sign.

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

                          @sgaist hi,

                          How to do it for version 5.13.1

                          Because i got confused. Now what I have to do?

                          Uninstall 5.9 version and try qmakr for 5.13.1 version?

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

                            Hi,

                            I got output.

                            In terminal,

                            I just ran sh configure -sql-mysql
                            after that ran make
                            after that ran make install

                            Thanks for your valuable support and valuable time.

                            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