Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Issues connecting QT to MYSQL
Forum Updated to NodeBB v4.3 + New Features

Issues connecting QT to MYSQL

Scheduled Pinned Locked Moved Solved Installation and Deployment
15 Posts 5 Posters 1.8k 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.
  • R Offline
    R Offline
    Richard1973
    wrote on last edited by
    #5

    @Christian-Ehrlicher So how do I fixed this?

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

      Hi,

      As @jsulm already wrote: use the full path to the qmake executable from your Qt 5.15 installation.

      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
      1
      • R Offline
        R Offline
        Richard1973
        wrote on last edited by
        #7

        @SGaist So I tried to make a path to the qt qmake, but I have no idea how since I am still new to ubuntu. For what its worth, when I type qmake -version, I get both the linux version 5.12.8 and the qt version 3.1. I tried using chmod but I am getting a permission error. Besides, I am not sure I am doing what you are explaining. Can you please tell me how to do this?

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

          In the console, type the full path to where you have the qmake executable.

          Something like:

          /home/username/Qt/5.15.2/gcc_64/bin/qmake
          

          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
          1
          • R Offline
            R Offline
            Richard1973
            wrote on last edited by
            #9

            @SGaist So i typed:
            /home/luden/Qt/5.15.2/gcc_64/bin/qmake -- MYSQL_PREFIX=/usr/local
            and it detected the MySql has a yes. However, when I type make sub-mysql, I get what looks like the same error as above:

            make sub-mysql
            cd mysql/ && ( test -e Makefile || /home/luden/Qt/5.15.2/gcc_64/bin/qmake -o Makefile /home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro ) && make -f Makefile
            make[1]: Entering directory '/home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql'
            g++ -c -g -O2 -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 -Wno-deprecated-copy -Wno-redundant-move -Wno-format-overflow -Wno-init-list-lifetime -D_REENTRANT -fPIC -DQT_NO_JAVA_STYLE_ITERATORS -DQT_DEPRECATED_WARNINGS -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.12.8 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.12.8 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.12.8/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
            qsql_mysql.cpp: In constructor ‘QMYSQLDriverPrivate::QMYSQLDriverPrivate()’:
            qsql_mysql.cpp:83:42: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
            83 | , tc(QTextCodec::codecForLocale())
            | ^
            In file included from qsql_mysql.cpp:57:
            /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:66:5: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate()’
            66 | QSqlDriverPrivate()
            | ^~~~~~~~~~~~~~~~~
            /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:66:5: note: candidate expects 0 arguments, 1 provided
            /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate(const QSqlDriverPrivate&)’
            61 | class QSqlDriverPrivate : public QObjectPrivate
            | ^~~~~~~~~~~~~~~~~
            /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: no known conversion for argument 1 from ‘QSqlDriver::DbmsType’ to ‘const QSqlDriverPrivate&’
            /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriverPrivate&&)’
            /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: no known conversion for argument 1 from ‘QSqlDriver::DbmsType’ to ‘QSqlDriverPrivate&&’
            qsql_mysql.cpp: In member function ‘virtual bool QMYSQLDriver::open(const QString&, const QString&, const QString&, const QString&, int, const QString&)’:
            qsql_mysql.cpp:1243:65: error: ‘SkipEmptyParts’ is not a member of ‘Qt’
            1243 | const QStringList opts(connOpts.split(QLatin1Char(';'), Qt::SkipEmptyParts));
            | ^~~~~~~~~~~~~~

            make[1]: *** [Makefile:384: .obj/qsql_mysql.o] Error 1
            make[1]: Leaving directory '/home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql'
            make: *** [Makefile:45: sub-mysql] Error 2

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

              Cleanup the sources as explained in the documentation and restart the procedure.

              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
              1
              • R Offline
                R Offline
                Richard1973
                wrote on last edited by
                #11

                @SGaist I have tried to uninstall and reinstall the src from the qt maintenance. But I still get the same error. I tried looking up "cleanup sources" on the qt documentation website and got nothing. Do you have the documentation link that explains this procedure?

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #12

                  Hi, it's more difficult when you have 2 different versions of Qt installed in the same Ubuntu system, that's why you get this error:
                  qsql_mysql.cpp:83:42: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’

                  The 2 different Qt versions are fighting each other (as @Christian-Ehrlicher said above: SqlDriverPrivate(QSqlDriver::DbmsType) was added in 5.15 and replaced QSqlDriverPrivate)

                  Maybe you could try uninstalling of the 2 Qts...

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

                    Look at the note under Building The Drivers.

                    Also, consider using out of source builds, that will makes things simpler to clean on error/retry.

                    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
                    1
                    • R Richard1973

                      @jsulm Thank you for that reply. I managed to get qmake working after installing the qt5-default. Now I am having problems running make sub-mysql. The first error fatal error: QtSql/private/qsqldriver_p.h which I managed to solve by installing the qt5-private-dev.

                      Now I am getting a new error:
                      luden@luden-desktop:~/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers$ make sub-mysql
                      cd mysql/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro MYSQL_PREFIX=/var/lib ) && make -f Makefile
                      make[1]: Entering directory '/home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql'
                      g++ -c -g -O2 -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 -Wno-deprecated-copy -Wno-redundant-move -Wno-format-overflow -Wno-init-list-lifetime -D_REENTRANT -fPIC -DQT_NO_JAVA_STYLE_ITERATORS -DQT_DEPRECATED_WARNINGS -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.12.8 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.12.8 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.12.8/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
                      qsql_mysql.cpp: In constructor ‘QMYSQLDriverPrivate::QMYSQLDriverPrivate()’:
                      qsql_mysql.cpp:83:42: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
                      83 | , tc(QTextCodec::codecForLocale())
                      | ^
                      In file included from qsql_mysql.cpp:57:
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:66:5: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate()’
                      66 | QSqlDriverPrivate()
                      | ^~~~~~~~~~~~~~~~~
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:66:5: note: candidate expects 0 arguments, 1 provided
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate(const QSqlDriverPrivate&)’
                      61 | class QSqlDriverPrivate : public QObjectPrivate
                      | ^~~~~~~~~~~~~~~~~
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: no known conversion for argument 1 from ‘QSqlDriver::DbmsType’ to ‘const QSqlDriverPrivate&’
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriverPrivate&&)’
                      /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: no known conversion for argument 1 from ‘QSqlDriver::DbmsType’ to ‘QSqlDriverPrivate&&’
                      qsql_mysql.cpp: In member function ‘virtual bool QMYSQLDriver::open(const QString&, const QString&, const QString&, const QString&, int, const QString&)’:
                      qsql_mysql.cpp:1243:65: error: ‘SkipEmptyParts’ is not a member of ‘Qt’
                      1243 | const QStringList opts(connOpts.split(QLatin1Char(';'), Qt::SkipEmptyParts));
                      | ^~~~~~~~~~~~~~

                      make[1]: *** [Makefile:384: .obj/qsql_mysql.o] Error 1
                      make[1]: Leaving directory '/home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql'
                      make: *** [Makefile:45: sub-mysql] Error 2

                      I read somewhere about using QT_VERSION_CHECK (https://github.com/MaartenBaert/ssr/issues/809), but I am not sure if that will help me nor do I know how to use it.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @Richard1973 said in Issues connecting QT to MYSQL:

                      I managed to get qmake working after installing the qt5-default

                      No, you did not. Instead of simply using absolute path to qmake you installed a different Qt version...

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Richard1973
                        wrote on last edited by
                        #15

                        So I uninstalled qt5-deafult using sudo apt-remove. When i tried to do the same for the private-dev it just says that it cant find the package. I used maintenance tool to remove everything. For good measures I restarted my computer. I then used run, installed everything for 5.15.2 and for teh developer and creator install the default cmake and ninja.
                        I then created a new project to connect mysql and qt. Followed the instructions from teh sql-driver. The qmake did not come back with an error and make sub-mysql seems to have worked as well. When I went to reconnect, I still got the same Debug Error as above. But after using make install, everything seems to work now. Even managed to connect and extract information from mysql. So thank you everyone who has helped me.

                        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