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. Integration MySQL and Qt5.7?
QtWS25 Last Chance

Integration MySQL and Qt5.7?

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
mysqlqt5.7
10 Posts 3 Posters 4.2k 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.
  • T Offline
    T Offline
    Tom_DE
    wrote on 14 Jul 2016, 06:14 last edited by
    #1

    Hello everyone,
    I've been looking for a solution to get MySQL working with Qt 5.7 on a Ubuntu machine. The MySQL database is working properly, but I can't figure out how to make the drivers work for Qt. I have tried the SQL browser example code as a base to identify the problem. After trying to make connection to MySQL, the application output displays 'QSqlDatabase: QMYSQL driver not loaded' and 'QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7'. This got me confused at first as I thought they were there. After some googling for answer it seems the libmysqlclient_r.so.16 cannot be found. As it turns out I have .so.20 installed. The forums recommended on build them yourself. I don't quite understand how to qmake and make the appropriate files necessary to run the Mysql service. As so I have tried but have been unsuccessful so I come asking the forums for help. I'm not very experienced in Linux itself and a first time user of Qt.

    Any help would be greatly appreciated.
    Thanks in advance,
    Tom

    R 1 Reply Last reply 14 Jul 2016, 06:28
    0
    • T Tom_DE
      14 Jul 2016, 06:14

      Hello everyone,
      I've been looking for a solution to get MySQL working with Qt 5.7 on a Ubuntu machine. The MySQL database is working properly, but I can't figure out how to make the drivers work for Qt. I have tried the SQL browser example code as a base to identify the problem. After trying to make connection to MySQL, the application output displays 'QSqlDatabase: QMYSQL driver not loaded' and 'QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7'. This got me confused at first as I thought they were there. After some googling for answer it seems the libmysqlclient_r.so.16 cannot be found. As it turns out I have .so.20 installed. The forums recommended on build them yourself. I don't quite understand how to qmake and make the appropriate files necessary to run the Mysql service. As so I have tried but have been unsuccessful so I come asking the forums for help. I'm not very experienced in Linux itself and a first time user of Qt.

      Any help would be greatly appreciated.
      Thanks in advance,
      Tom

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 14 Jul 2016, 06:28 last edited by
      #2

      @Tom_DE
      see this

      But make sure you link against the same Qt version and use the same compiler.
      Otherwise you will most probably experience random crashes (if the plugin even loads)

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tom_DE
        wrote on 14 Jul 2016, 10:00 last edited by
        #3

        Thank you @raven-worx for the fast reply,
        I have followed the directions in the link provided before and from what understood from it, is that the $QTDIR/qtbase/src/plugins/sqldriver/mysql comes from the source code which you seperatly download?
        Perhaps I misunderstood this, but I haven't found the qtbase folder elsewhere.

        GCC Compiler version on my Ubuntu (which is 16.04) is 5.3.1, do you suggest downgrading it to the suggested version 4.8.1 for Ubuntu 14.04?
        The MySQL version my Ubuntu machine uses is as well a higher version: 5.7.12 should I downgrade it as well to the matching software version?

        Many thanks for your reply,
        Tom

        R 1 Reply Last reply 14 Jul 2016, 10:05
        0
        • T Tom_DE
          14 Jul 2016, 10:00

          Thank you @raven-worx for the fast reply,
          I have followed the directions in the link provided before and from what understood from it, is that the $QTDIR/qtbase/src/plugins/sqldriver/mysql comes from the source code which you seperatly download?
          Perhaps I misunderstood this, but I haven't found the qtbase folder elsewhere.

          GCC Compiler version on my Ubuntu (which is 16.04) is 5.3.1, do you suggest downgrading it to the suggested version 4.8.1 for Ubuntu 14.04?
          The MySQL version my Ubuntu machine uses is as well a higher version: 5.7.12 should I downgrade it as well to the matching software version?

          Many thanks for your reply,
          Tom

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 14 Jul 2016, 10:05 last edited by
          #4

          @Tom_DE said:

          Thank you @raven-worx for the fast reply,
          I have followed the directions in the link provided before and from what understood from it, is that the $QTDIR/qtbase/src/plugins/sqldriver/mysql comes from the source code which you seperatly download?

          yes

          GCC Compiler version on my Ubuntu (which is 16.04) is 5.3.1, do you suggest downgrading it to the suggested version 4.8.1 for Ubuntu 14.04?

          yes, IIRC at least gcc's major version need to match to ensure binary compatibility.

          The MySQL version my Ubuntu machine uses is as well a higher version: 5.7.12 should I downgrade it as well to the matching software version?

          You can give it a try. You will encounter mysql related compiler/linker errors anyway if they are not compatible anymore.
          But i suggest you use the same version.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tom_DE
            wrote on 14 Jul 2016, 11:12 last edited by
            #5

            I've downgraded my GCC to 4.8.5 (i suspect it is close enough to the major version.
            I have not yet changed the MySQL version as it does not change the result of this problem.

            The source code I tried to qmake but it gives me an error : qmake: could not find a Qt installation of ''
            Is this because I have no qmake installation? Should I completly try to reinstall Qt for that?

            Kind thanks to you, @raven-worx for your help so far.

            R 1 Reply Last reply 14 Jul 2016, 11:29
            0
            • T Tom_DE
              14 Jul 2016, 11:12

              I've downgraded my GCC to 4.8.5 (i suspect it is close enough to the major version.
              I have not yet changed the MySQL version as it does not change the result of this problem.

              The source code I tried to qmake but it gives me an error : qmake: could not find a Qt installation of ''
              Is this because I have no qmake installation? Should I completly try to reinstall Qt for that?

              Kind thanks to you, @raven-worx for your help so far.

              R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 14 Jul 2016, 11:29 last edited by
              #6

              @Tom_DE said:

              The source code I tried to qmake but it gives me an error : qmake: could not find a Qt installation of ''
              Is this because I have no qmake installation? Should I completly try to reinstall Qt for that?

              to make sure call qmake with the absolute path

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              T 1 Reply Last reply 14 Jul 2016, 11:35
              0
              • R raven-worx
                14 Jul 2016, 11:29

                @Tom_DE said:

                The source code I tried to qmake but it gives me an error : qmake: could not find a Qt installation of ''
                Is this because I have no qmake installation? Should I completly try to reinstall Qt for that?

                to make sure call qmake with the absolute path

                T Offline
                T Offline
                Tom_DE
                wrote on 14 Jul 2016, 11:35 last edited by
                #7

                @raven-worx

                @raven-worx said:

                to make sure call qmake with the absolute path

                Could you elaborate on that? As in what the absolute is in : qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro ?

                R 1 Reply Last reply 14 Jul 2016, 11:38
                0
                • T Tom_DE
                  14 Jul 2016, 11:35

                  @raven-worx

                  @raven-worx said:

                  to make sure call qmake with the absolute path

                  Could you elaborate on that? As in what the absolute is in : qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro ?

                  R Offline
                  R Offline
                  raven-worx
                  Moderators
                  wrote on 14 Jul 2016, 11:38 last edited by
                  #8

                  @Tom_DE

                  /path/to/your/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
                  

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    Tom_DE
                    wrote on 14 Jul 2016, 11:51 last edited by
                    #9

                    Is the following command correct? (sorry for the lack of knowledge of Linux)

                    delta@delta-engineering:~/Downloads/qt-everywhere-opensource-src-5.7.02/qtbase/src/plugins/sqldrivers$ /home/delta/Qt/5.7/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro

                    If so this is the error it gives.
                    Cannot find file: mysql.pro.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 14 Jul 2016, 21:55 last edited by
                      #10

                      Hi and welcome to devnet,

                      You have to go to the mysql plugin 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

                      5/10

                      14 Jul 2016, 11:12

                      • Login

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