Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5.12.0 QMYSQL plugin
Qt 6.11 is out! See what's new in the release blog

Qt5.12.0 QMYSQL plugin

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 3 Posters 5.4k 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.
  • D Offline
    D Offline
    dnovichman
    wrote on last edited by
    #1

    I am new to QT and have been trying to connect to a mysql database using
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

    Unfortunately Qt5.12.0 does not have this plugin loaded by default hence I kept getting the following errors
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

    doing an ldd on the precompiled libqsqlmysql.so shows that it is trying to use libmysqlclient18 instead of the libmysqlclient20 that is the default sql client library on Ubuntu 16.04. Without any success, I've tried to rebuild the plugin with the following

    '/home/dnovichman/Qt5.12.0/5.12.0/gcc_64/bin/qmake' "INCLUDEPATH+=-I/usr/include/mysql" "LIBS+=-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl" mysql.pro
    undefined reference to `QSqlField::QSqlField(QString const&, QVariant::Type, QString const&)'

    Unfortunately, I'm getting a lot of undefined references like
    undefined reference to QSqlResult::QSqlResult(QSqlResultPrivate&)' .obj/qsql_mysql.o:(.qtversion[qt_version_tag]+0x0): undefined reference to qt_version_tag'

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

      Hi and welcome to devnet,

      Where did you get the Qt sources from ?

      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
      • D Offline
        D Offline
        dnovichman
        wrote on last edited by
        #3

        I downloaded qt-unified-linux-x64-3.0.6-online.run from http://qt.mirrors.tds.net using this page https://www.qt.io/download-qt-installer?hsCtaTracking=9f6a2170-a938-42df-a8e2-a9f0b1d6cdce|6cb0de4f-9bb5-4778-ab02-bfb62735f3e5

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

          The custom build logic has changed a bit. Are you following the guide ?

          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
          • D Offline
            D Offline
            dnovichman
            wrote on last edited by
            #5

            I've followed those instructions and rebuilt the entire QT by running the following commands from ~/Qt5.12.0/5.12.0/Src

            ./configure -sql-mysql
            make install

            That did still had the libqsmysql.so linking to libmysqlclient18 instead of libmysqlclient20.

            Unfortunately, doing these additional commands
            cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
            make install

            Led to the current undefined reference compile issue

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

              When calling make install, what was the folder used for the 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
              0
              • D Offline
                D Offline
                dnovichman
                wrote on last edited by
                #7

                For ./configure -sql-mysql, make install was run in ~/Qt5.12.0/5.12.0/Src and for $QTDIR/qtbase/src/plugins/sqldrivers/mysql, make install was run in the $QTDIR/qtbase/src/plugins/sqldrivers/mysql

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

                  I meant the target folder.

                  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
                  • D Offline
                    D Offline
                    dnovichman
                    wrote on last edited by
                    #9

                    Using MYSQL_PREFIX=/usr/include/mysql
                    and target is sub-mysql

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      lolo220
                      Banned
                      wrote on last edited by mrjj
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        dnovichman
                        wrote on last edited by
                        #11

                        This is meant to rebuild only the mysql plugin but ends up re-building all of Qt (with open source option)

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

                          I meant: what folder did you configure to have Qt installed to.

                          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
                          • D Offline
                            D Offline
                            dnovichman
                            wrote on last edited by
                            #13

                            The default directory which I believe is ~/Qt5.12.0

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

                              Can you check that ?

                              Looking at the output of make install should show you exactly what is copied where.

                              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
                              • D Offline
                                D Offline
                                dnovichman
                                wrote on last edited by
                                #15

                                My Qt is installed in ~/Qt5.12.0. This has qt creator, qmake, gcc and android versions including the compiled libraries.

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

                                  That I understood. Nevertheless, could you check as suggested the output of make install ?

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

                                    The installation directory is /usr/local/Qt-5.12.0

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

                                      Then that's where you custom built MySQL plugin can be found.

                                      You likely have built it from a default configured Qt build hence that location.

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

                                      D 1 Reply Last reply
                                      0
                                      • SGaistS SGaist

                                        Then that's where you custom built MySQL plugin can be found.

                                        You likely have built it from a default configured Qt build hence that location.

                                        D Offline
                                        D Offline
                                        dnovichman
                                        wrote on last edited by dnovichman
                                        #19

                                        @SGaist I tried doing a clean build today in ~/Qt5.12.0/5.12.0/Src with the following commands,

                                        make clean
                                        ./configure -sql-mysql
                                        make install

                                        I still ended up with the original errors regarding qt version and some functions not found.

                                        Surprisingly, when I did
                                        ldd /usr/local/Qt-5.12.0/plugins/sqldrivers/libqsqlmysql.so

                                        There are no errors and it is linking to libmysqlclient.so.20 and using the qt that is in this location works flawlessly.

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

                                          I recommend using out of source builds, so if something goes awry, you can nuke the build folder without having to look out for leftovers of previous builds.

                                          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

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved