Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    Mobile and Embedded
    4
    29
    2153
    Loading More Posts
    • 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
      Surendar Dharani last edited by

      @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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • S
          Surendar Dharani last edited by Surendar Dharani

          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 Reply Quote 0
          • S
            Surendar Dharani last edited by

            Please anyone help on this. Thanks a lot in advance

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • RonaldViscarraL
                RonaldViscarraL last edited by

                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 Reply Quote 0
                • S
                  Surendar Dharani @RonaldViscarraL last edited by

                  @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.

                  RonaldViscarraL 1 Reply Last reply Reply Quote 0
                  • RonaldViscarraL
                    RonaldViscarraL @Surendar Dharani last edited by 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 1 Reply Last reply Reply Quote 0
                    • S
                      Surendar Dharani @RonaldViscarraL last edited by

                      @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?

                      RonaldViscarraL 1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        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 Reply Quote 0
                        • RonaldViscarraL
                          RonaldViscarraL last edited by

                          @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 Reply Quote 0
                          • S
                            Surendar Dharani @RonaldViscarraL last edited by Surendar Dharani

                            @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 Reply Quote 0
                            • Quang Phu
                              Quang Phu last edited by

                              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 Reply Quote 0
                              • S
                                Surendar Dharani @Quang Phu last edited by Surendar Dharani

                                @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 Reply Quote 0
                                • SGaist
                                  SGaist Lifetime Qt Champion last edited by

                                  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 Reply Quote 0
                                  • S
                                    Surendar Dharani @SGaist last edited by

                                    @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 Reply Quote 0
                                    • S
                                      Surendar Dharani last edited by

                                      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 Reply Quote 0
                                      • First post
                                        Last post