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. Setting up the Qt Mysql driver with Lampp in Ubuntu
Forum Updated to NodeBB v4.3 + New Features

Setting up the Qt Mysql driver with Lampp in Ubuntu

Scheduled Pinned Locked Moved Solved Installation and Deployment
8 Posts 3 Posters 2.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.
  • AritzA Offline
    AritzA Offline
    Aritz
    wrote on last edited by
    #1

    I'm trying to set up the Mysql driver for qt5 (5.6, specifically) in my Xubuntu computer. As the Mysql installation is Lampp based, the standard configuration script doesn't work to set it up. So I've tried configuring it Myself, this way:

    cd /opt/Qt5.6.3/5.6.3/Src/qtbase/src/plugins/sqldrivers/mysql
    sudo /opt/Qt5.6.3/5.6.3/Src/qtbase/bin/qmake "INCLUDEPATH+=/opt/lampp/lib" "LIBS+=-L/opt/lampp/lib -lmysqlclient_r" mysql.pro
    

    Still, I get this error:

    Project ERROR: No module claims plugin type 'sqldrivers'
    

    Any idea of what am I doing wrong? Thanks in advanced.

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

      Hi and welcome to devnet,

      Did you build your own version of Qt inside the Src 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
      • AritzA Offline
        AritzA Offline
        Aritz
        wrote on last edited by
        #3

        Hello @SGaist

        One of my teammates prepared a Virtual Machine with Xubuntu and the Qt download. About building it, I'm not sure, if I do qmake version I get:

        qmake -version
        QMake version 2.01a
        Using Qt version 4.8.7 in /usr/lib/x86_64-linux-gnu
        

        So Xubuntu has the 4.8.7 version installed, but as I am going to develop for 5.6, I have it installed and Qt creator pointed to that folder. Is there anything I'm missing?

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

          Always use the full path to the qmake executable of the Qt version your want to use.

          There's no need to build the whole of Qt juste to build one of the plugin. The documentation of the SQL module provides the information about how to build specific DB plugins.

          You should also do out of source builds, it's never a good idea to build stuff as root.

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

            Ok, then I should always use the full path and don't use sudo, I understand:

            /opt/Qt5.6.3/5.6.3/Src/qtbase/bin/qmake -version
            QMake version 3.0
            Using Qt version 5.6.3 in /usr/local/Qt-5.6.3/lib
            

            Then, based in the documentation, I'm going to try to build the plugin using the Makefile. I do:

            cd /opt/Qt5.6.3/5.6.3/Src/qtbase/src/plugins/sqldrivers
            /opt/Qt5.6.3/5.6.3/Src/qtbase/bin/qmake --MYSQL_PREFIX=/opt/lampp/lib Makefile
            

            And I get:

            Unknown option --MYSQL_PREFIX=/opt/lampp/lib
            Usage: /opt/Qt5.6.3/5.6.3/Src/qtbase/bin/qmake [mode] [options] [files]
            

            EDIT

            I'm now trying to follow the steps in docs for 5.6, which are slightly different. I try:

            cd /opt/Qt5.6.3/5.6.3/Src/qtbase/src/plugins/sqldrivers/mysql
            sudo /opt/Qt5.6.3/5.6.3/Src/qtbase/bin/qmake "INCLUDEPATH+=/opt/lampp/include" "LIBS+=-L/opt/lampp/lib -libmysqlclient_r"  mysql.pro 
            

            And I get:

            Project ERROR: No module claims plugin type 'sqldrivers'
            
            1 Reply Last reply
            0
            • AritzA Offline
              AritzA Offline
              Aritz
              wrote on last edited by
              #6

              This steps seemed to properly configure the mysql driver. The way to check it is with this command:

              sudo /opt/Qt5.6.3/5.6.3/Src/configure -opensource -confirm-license -qt-sql-mysql -no-xcb -v
              

              And the output for the plugin list should be qt for the mysql driver. Then, I still couldn't connect from my Qt program. There were some missing libraries, which I detected using these commands:

              cd /opt/Qt5.6.3/gcc_64/plugins/sqldrivers
              ldd libqsqlmysql.so
              

              Qt was looking for these libraries in the standard Unix path instead of the Lampp lib directory. So in the end I copied the missing libraries in the standard Unix path and got the connections working.

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

                You should set the LD_LIBRARY_PATH environment variable rather than modifying your system like that.

                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
                • AritzA Aritz

                  This steps seemed to properly configure the mysql driver. The way to check it is with this command:

                  sudo /opt/Qt5.6.3/5.6.3/Src/configure -opensource -confirm-license -qt-sql-mysql -no-xcb -v
                  

                  And the output for the plugin list should be qt for the mysql driver. Then, I still couldn't connect from my Qt program. There were some missing libraries, which I detected using these commands:

                  cd /opt/Qt5.6.3/gcc_64/plugins/sqldrivers
                  ldd libqsqlmysql.so
                  

                  Qt was looking for these libraries in the standard Unix path instead of the Lampp lib directory. So in the end I copied the missing libraries in the standard Unix path and got the connections working.

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

                  @Aritz said in Setting up the Qt Mysql driver with Lampp in Ubuntu:

                  sudo /opt/Qt5.6.3/5.6.3/Src/configure -opensource -confirm-license -qt-sql-mysql -no-xcb -v

                  Why sudo?

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

                  1 Reply Last reply
                  1

                  • Login

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