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 with building QMYSQL plugin
Forum Updated to NodeBB v4.3 + New Features

issues with building QMYSQL plugin

Scheduled Pinned Locked Moved Solved Installation and Deployment
59 Posts 3 Posters 23.0k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #20

    I just realised there's something fishy with the error message: the path seems to start at the root of the filesystem and doesn't match anything I know from the sources.

    Can you try a clean out of source build of the plugin from the console ?

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

    mzimmersM 1 Reply Last reply
    1
    • SGaistS SGaist

      I just realised there's something fishy with the error message: the path seems to start at the root of the filesystem and doesn't match anything I know from the sources.

      Can you try a clean out of source build of the plugin from the console ?

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by mzimmers
      #21

      @SGaist I deleted my Makefile and ran the following command:

      mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ /opt/Qt/5.8/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include /usr/src/mysql/mysql-5.7.17/include" "LIBS+=-L/usr/lib -lmysqlclient_r" /home/mzimmers/QtStuff/qtbase/src/plugins/sqldrivers/mysql/mysql.pro
      

      Question #1: what is the correct syntax for removing a compiler flag? I tried this:

      QMAKE_CXXFLAGS -= "-std=c++1z"
      

      but that didn't work.

      I then went in and manually modified the Makefile, changing "-std=c++1z" to "-std=c++11", and ran make. I then encountered this error:

      mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ make
      g++ -c -pipe -O2 -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -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/local/include -I/usr/src/mysql/mysql-5.7.17/include -I/opt/Qt/5.8/gcc_64/include/QtSql/5.8.0 -I/opt/Qt/5.8/gcc_64/include/QtSql/5.8.0/QtSql -I/opt/Qt/5.8/gcc_64/include/QtCore/5.8.0 -I/opt/Qt/5.8/gcc_64/include/QtCore/5.8.0/QtCore -I/opt/Qt/5.8/gcc_64/include -I/opt/Qt/5.8/gcc_64/include/QtSql -I/opt/Qt/5.8/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp
      In file included from qsql_mysql_p.h:60:0,
                       from qsql_mysql.cpp:40:
      /usr/src/mysql/mysql-5.7.17/include/mysql.h:57:27: fatal error: mysql_version.h: No such file or directory
       #include "mysql_version.h"
                                 ^
      compilation terminated.
      Makefile:834: recipe for target '.obj/qsql_mysql.o' failed
      make: *** [.obj/qsql_mysql.o] Error 1
      mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ 
      

      I don't have a file named mysql_version.h. I do have a file named mysql_version.h.in. I'm not familiar with .in files, but according to Wiki, it's input to a program called "autoconf." In reading the documentation, I wonder whether I somehow missed a step in the build that converts this .in file into a .h file. EDIT: I did find a cmake file with that name as well, though there's nothing in the documentation about running cmake manually.

      Anyway, we do seem to be moving forward. I would like to resolve this problem with the compiler flag, though.

      Thanks for all the help.

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

        Out of curiosity, why don't you install the MySQL dev package from your distribution ? That would certainly simplify things.

        As for your compiler, which version is it ?

        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
        • mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #23

          MySQL doesn't make a package for Debian. The compiler is 4.9.2. I asked about updating the compiler in a Debian forum, and got a lot of snarky answers telling me it was a bad idea.

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

            Sure there is: see libmysqlclient-dev.

            IIRC 4.9.2 should be good to build Qt 5.

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

            mzimmersM 1 Reply Last reply
            1
            • SGaistS SGaist

              Sure there is: see libmysqlclient-dev.

              IIRC 4.9.2 should be good to build Qt 5.

              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #25

              @SGaist I'm sorry; I misunderstood you -- when you said "from your distribution," I thought you meant part of the Debian package.

              Just to be clear, are you saying that with that package, I can better build the QMYSQL plugin, or that it's already included?

              And, for my education, I'd really like to know how to alter compiler flags on the command line. I've tried "QMAKE_CXXFLAGS -=" but that doesn't seem to do anything.

              Thanks.

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

                It will make things easier to build the plugin.

                IIRC CONFIG += c++11 should only enable C++11 feature and not later.

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

                mzimmersM 1 Reply Last reply
                0
                • SGaistS SGaist

                  It will make things easier to build the plugin.

                  IIRC CONFIG += c++11 should only enable C++11 feature and not later.

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #27

                  @SGaist I think we're getting closer. I installed the package you referenced above, and ran this qmake command:

                  /opt/Qt/5.8/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib/x86_64-linux-gnu/ -lmysqlclient_r" /home/mzimmers/QtStuff/qtbase/src/plugins/sqldrivers/mysql/mysql.pro/
                  

                  I then edited the Makefile, changing the 2 occurrences of "-std=c++1z" to "-std=c++11" and ran make. Here's the output:

                  mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ make
                  rm -f libqsqlmysql.so
                  g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../../lib -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/qsql_mysql.o .obj/main.o .obj/moc_qsql_mysql_p.o  -L/usr/lib -lmysqlclient_r -L/opt/Qt/5.8/gcc_64/lib -lQt5Sql -lQt5Core -L/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto -ldl  
                  /usr/bin/ld: cannot find -lmysqlclient_r
                  collect2: error: ld returned 1 exit status
                  Makefile:115: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
                  make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
                  mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ 
                  

                  I also tried LIBS+=-L/usr/lib/x86_64-linux-gnu (which is the actual directory) with the same results. Any idea what's wrong here?

                  Thank you.

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

                    You shouldn't need the -l parameter

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

                    mzimmersM 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      You shouldn't need the -l parameter

                      mzimmersM Offline
                      mzimmersM Offline
                      mzimmers
                      wrote on last edited by
                      #29

                      @SGaist OK, I removed it. Here are the results:

                      mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ /opt/Qt/5.8/gcc_64/bin/qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib/" ./mysql.pro
                      mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ make
                      rm -f libqsqlmysql.so
                      g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../../lib -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/qsql_mysql.o .obj/main.o .obj/moc_qsql_mysql_p.o  -L/usr/lib/ -L/opt/Qt/5.8/gcc_64/lib -lQt5Sql -lQt5Core -L/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto -ldl  
                      /usr/bin/ld: cannot find -lz
                      /usr/bin/ld: cannot find -lssl
                      /usr/bin/ld: cannot find -lcrypto
                      collect2: error: ld returned 1 exit status
                      Makefile:115: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
                      make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
                      mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ 
                      

                      I don't know whether this is progress or a step back. Do I need to specify paths for the libraries that make can't find?

                      On a more general note: I notice that I seem to be needing to do a lot of things that aren't mentioned on the page that talks about building this plugin. Is the page incomplete, or is there something atypical about my Qt installation?

                      Thanks.

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

                        You need the development packages for OpenSSL and zlib.

                        That's rather a side effect of the dependencies of the 3rd party that can change over time.

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

                        mzimmersM 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          You need the development packages for OpenSSL and zlib.

                          That's rather a side effect of the dependencies of the 3rd party that can change over time.

                          mzimmersM Offline
                          mzimmersM Offline
                          mzimmers
                          wrote on last edited by
                          #31

                          @SGaist so, I need these?

                          https://www.openssl.org/source/openssl-1.1.0e.tar.gz
                          http://www.zlib.net/zlib-1.2.11.tar.gz

                          They aren't explicitly labeled "development packages" but I'm hoping this is what I need...

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

                            It seems you are forgetting you are running Linux ;)

                            Use your distributions package manager for that like you did to install the MySQL development package.

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

                            mzimmersM 1 Reply Last reply
                            2
                            • SGaistS SGaist

                              It seems you are forgetting you are running Linux ;)

                              Use your distributions package manager for that like you did to install the MySQL development package.

                              mzimmersM Offline
                              mzimmersM Offline
                              mzimmers
                              wrote on last edited by
                              #33

                              @SGaist believe it or not, I did look there first, but I wasn't sure what to choose. My best guesses would be:

                              openssl - Secure Sockets Layer toolkit - cryptographic utility
                              zlib1g-dev - compression library - development

                              (I found these among the results of an apt-cache search for openssl and zlib.)

                              Did I guess well?

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

                                Sorry, it's libssl-dev the OpenSSL package is the command line client.
                                As for zlib, yes

                                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
                                • mzimmersM Offline
                                  mzimmersM Offline
                                  mzimmers
                                  wrote on last edited by
                                  #35

                                  I installed those two, and here is the output:```
                                  mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$ make
                                  rm -f libqsqlmysql.so
                                  g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../../lib -Wl,-rpath,$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/qsql_mysql.o .obj/main.o .obj/moc_qsql_mysql_p.o -L/usr/lib/x86_64-linux-gnu/ -lmysqlclient_r -L/opt/Qt/5.8/gcc_64/lib -lQt5Sql -lQt5Core -L/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto -ldl
                                  /usr/bin/ld: cannot find -lmysqlclient_r
                                  collect2: error: ld returned 1 exit status
                                  Makefile:115: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
                                  make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
                                  mzimmers@debian:~/QtStuff/qtbase/src/plugins/sqldrivers/mysql$

                                  I have a file called "libmysqlclient_r.so.18" in /usr/lib/x86_64-linux-gnu...is this not the library it wants?
                                  
                                  Thanks. I appreciate your staying up so late to help me with this.
                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #36

                                    It looks like you didn't install the libmysqlclient-dev package.

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

                                    mzimmersM 1 Reply Last reply
                                    1
                                    • SGaistS SGaist

                                      It looks like you didn't install the libmysqlclient-dev package.

                                      mzimmersM Offline
                                      mzimmersM Offline
                                      mzimmers
                                      wrote on last edited by
                                      #37

                                      @SGaist yes I did. I just tried again, and apt-get confirmed I'm up to date on this package. And according to the file list on the page you linked, the libraries are in the right location:

                                      mzimmers@debian:/usr/lib/x86_64-linux-gnu$ pwd
                                      /usr/lib/x86_64-linux-gnu
                                      mzimmers@debian:/usr/lib/x86_64-linux-gnu$ ls libmy*
                                      libmysqlclient.a        libmysqlclient_r.so.18.0.0  libmysqlclient.so.18      libmysqlclient.so.20      libmysqlservices.a
                                      libmysqlclient_r.so.18  libmysqlclient.so           libmysqlclient.so.18.0.0  libmysqlclient.so.20.3.4
                                      mzimmers@debian:/usr/lib/x86_64-linux-gnu$ 
                                      
                                      
                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #38

                                        There's something strange here, you are missing at least the libmysqlclient_r.so symlink in that folder.

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

                                        mzimmersM 1 Reply Last reply
                                        0
                                        • SGaistS SGaist

                                          There's something strange here, you are missing at least the libmysqlclient_r.so symlink in that folder.

                                          mzimmersM Offline
                                          mzimmersM Offline
                                          mzimmers
                                          wrote on last edited by
                                          #39

                                          @SGaist I just did an apt-get remove and another install...same files. Should I file a bug report in the Debian forum?

                                          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