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. Unable to compile SQL plugin
Forum Updated to NodeBB v4.3 + New Features

Unable to compile SQL plugin

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
15 Posts 5 Posters 1.5k 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.
  • Anton1978A Anton1978

    Good day.
    I wrote a small program to understand how Qt c ++ and SQL works.
    She writes to me:

    QSqlQuery::exec: database not open
    QSqlError("", "Driver not loaded", "Driver not loaded")
    ("QSQLITE", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    

    After reading the Internet, I found out that I needed a SQL plugin, I found this instruction https://doc.qt.io/qt-5/sql-driver.html#qpsql (Why are plugins not working out of the box? It doesn't matter.)
    Ok. I go to the folder ~/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers
    Do "qmake -- PSQL_INCDIR=/usr/include/pgsql"
    Ok

    Running configuration tests...
    Done running configuration tests.
    
    Configure summary:
    
    Qt Sql Drivers:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. no
      OCI (Oracle) ........................... no
      ODBC ................................... no
      PostgreSQL ............................. yes
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    
    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into '/usr'.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

    Do "make sub-psql"
    And I get

    cd psql/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql/psql.pro PSQL_INCDIR=/usr/include/pgsql ) && make -f Makefile
    make[1]: вход в каталог «/home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql»
    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/postgresql -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/qsql_psql.o qsql_psql.cpp
    qsql_psql.cpp: In constructor ‘QPSQLDriverPrivate::QPSQLDriverPrivate()’:
    qsql_psql.cpp:152:68: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
      152 |     QPSQLDriverPrivate() : QSqlDriverPrivate(QSqlDriver::PostgreSQL) {}
          |                                                                    ^
    In file included from qsql_psql.cpp:55:
    /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&&’
    make[1]: *** [Makefile:384: .obj/qsql_psql.o] Error 1
    make[1]: выход из каталога «/home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql»
    make: *** [Makefile:45: sub-psql] Error 2
    

    What's happening? I just need to work with SQL, but that's all. If we open the sqldrivers.pro project using QtCreator, and try to compile, we get 3 errors:

    /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp:147: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
    /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp:147:73: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
      147 |     inline QSQLiteDriverPrivate() : QSqlDriverPrivate(QSqlDriver::SQLite) {}
          |                                                                         ^
    
    /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql/qsql_psql.cpp:152: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
    /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql/qsql_psql.cpp:152:68: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
      152 |     QPSQLDriverPrivate() : QSqlDriverPrivate(QSqlDriver::PostgreSQL) {}
          |                                                                    ^
    
    :-1: Error: [Makefile:845: .obj/qsql_sqlite.o] Error 1
    

    How do I get the plugin?
    I'm using communiti QtCreator, PostgreSQL 13.1 , Ubuntu 20.04

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

    @Anton1978 You forgot to mention what database you want to use actually?
    Looks like you want to use PostgreSQL. If this is the case there is no need to build anything, the plug-in is delivered with Qt (libqsqlpsql.so).
    For MySQL you have to build it by yourself because of MySQL license reasons.
    If the plug-in is not loaded then do this: set QT_DEBUG_PLUGINS env variable and then start your app. I guess PostgreSQL client library is not installed.

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

    Anton1978A 1 Reply Last reply
    1
    • jsulmJ jsulm

      @Anton1978 You forgot to mention what database you want to use actually?
      Looks like you want to use PostgreSQL. If this is the case there is no need to build anything, the plug-in is delivered with Qt (libqsqlpsql.so).
      For MySQL you have to build it by yourself because of MySQL license reasons.
      If the plug-in is not loaded then do this: set QT_DEBUG_PLUGINS env variable and then start your app. I guess PostgreSQL client library is not installed.

      Anton1978A Offline
      Anton1978A Offline
      Anton1978
      wrote on last edited by Anton1978
      #3

      @jsulm Yes, use PostgreSQL. If i enter the command "sudo apt install postgresql-client-13"
      then the terminal writes "The most recent version of postgresql-client-13 package (13.1-1.pgdg20.04 + 1) is already installed.
      postgresql-client-13 is marked as manually installed."

      the output after export QT_DEBUG_PLUGINS = 1 is huge, even larger than the code of the program itself.
      Here it is, what would you advise to look for there?

      https://cloud.mail.ru/public/3tnm/Zn2pjp1qr

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #4

        You called the wrong qmake so the wrong headers are picked up. Call the qmake from your Qt version you're trying to compile the plugin for (I would guess it's 5.15 and not 5.12).
        Same problem here: https://forum.qt.io/topic/121095/issues-connecting-qt-to-mysql/9

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • Anton1978A Offline
          Anton1978A Offline
          Anton1978
          wrote on last edited by
          #5

          tried to do so
          '~/Qt/5.15.2/gcc_64/bin/qmake -- PSQL_INCDIR=/usr/include/pgsql'
          Ok

          anton@home:~/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers$ ~/Qt/5.15.2/gcc_64/bin/qmake -- PSQL_INCDIR=/usr/include/pgsql
          
          Running configuration tests...
          Done running configuration tests.
          
          Configure summary:
          
          Qt Sql Drivers:
            DB2 (IBM) .............................. no
            InterBase .............................. no
            MySql .................................. no
            OCI (Oracle) ........................... no
            ODBC ................................... no
            PostgreSQL ............................. yes
            SQLite2 ................................ no
            SQLite ................................. yes
              Using system provided SQLite ......... no
            TDS (Sybase) ........................... no
          
          Qt is now configured for building. Just run 'make'.
          Once everything is built, you must run 'make install'.
          Qt will be installed into '/home/anton/Qt/5.15.2/gcc_64'.
          
          Prior to reconfiguration, make sure you remove any leftovers from
          the previous build.
          

          Ok, do it 'make sub-psql'
          And...

          anton@home:~/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers$ make sub-psql
          cd psql/ && ( test -e Makefile || /home/anton/Qt/5.15.2/gcc_64/bin/qmake -o Makefile /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql/psql.pro ) && make -f Makefile
          make[1]: вход в каталог «/home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql»
          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/postgresql -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/qsql_psql.o qsql_psql.cpp
          qsql_psql.cpp: In constructor ‘QPSQLDriverPrivate::QPSQLDriverPrivate()’:
          qsql_psql.cpp:152:68: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
            152 |     QPSQLDriverPrivate() : QSqlDriverPrivate(QSqlDriver::PostgreSQL) {}
                |                                                                    ^
          In file included from qsql_psql.cpp:55:
          /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&&’
          make[1]: *** [Makefile:384: .obj/qsql_psql.o] Ошибка 1
          make[1]: выход из каталога «/home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql»
          make: *** [Makefile:45: sub-psql] Ошибка 2
          

          it looks like mockery

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @Anton1978 said in Unable to compile SQL plugin:

            /usr/include/x86_64-linux-gnu/qt5/QtCore/5.12.8

            Still using the wrong include paths. Make sure to start with a clean source dir.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • Anton1978A Offline
              Anton1978A Offline
              Anton1978
              wrote on last edited by
              #7

              I really don't understand why this is happening? I am explicitly specifying which qmake to use - '~/Qt/5.15.2/gcc_64/bin/qmake'
              Even if I write like this
              ~/Qt/5.15.2/gcc_64/bin/qmake -- PSQL_INCDIR=~/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers
              the result does not change
              why is the file used
              /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h

              I think me need some rest

              1 Reply Last reply
              0
              • Anton1978A Offline
                Anton1978A Offline
                Anton1978
                wrote on last edited by Anton1978
                #8

                Another interesting point, if you open the SQLPlagin project in QTCreator, you can see that the sources with errors
                /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/sqldrivers.pro
                have 3 errors

                /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql/qsql_psql.cpp:152: error: no matching constructor for initialization of 'QSqlDriverPrivate' 
                
                :-1: error: [Makefile:845: .obj/qsql_sqlite.o] Error 1
                
                /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql/qsql_psql.cpp:152: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
                /home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql/qsql_psql.cpp:152:68: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
                  152 |     QPSQLDriverPrivate() : QSqlDriverPrivate(QSqlDriver::PostgreSQL) {}
                

                He writes to me about these errors when using make.
                But for others it compiles.
                Some kind of mysticism.

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  Again: start with a clean source dir and call the correct qmake.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • eyllanescE Offline
                    eyllanescE Offline
                    eyllanesc
                    wrote on last edited by eyllanesc
                    #10

                    It is not necessary to compile the plugin but it is only necessary to install the client, in the case of Ubuntu it is enough with:

                    sudo apt-get install libpq-dev
                    

                    If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                    Anton1978A 1 Reply Last reply
                    0
                    • eyllanescE eyllanesc

                      It is not necessary to compile the plugin but it is only necessary to install the client, in the case of Ubuntu it is enough with:

                      sudo apt-get install libpq-dev
                      
                      Anton1978A Offline
                      Anton1978A Offline
                      Anton1978
                      wrote on last edited by
                      #11

                      @eyllanesc
                      It's installed, everything doesn't work

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

                        Hi,

                        As @Christian-Ehrlicher wrote, you have to clean the sources before starting fresh. There are also hidden files in the folder that you need to remove (you can find that here).

                        If you want to be on the safe side, you can even to an out of source build.

                        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
                        • Anton1978A Anton1978

                          @eyllanesc
                          It's installed, everything doesn't work

                          eyllanescE Offline
                          eyllanescE Offline
                          eyllanesc
                          wrote on last edited by
                          #13

                          @Anton1978 It is very strange since I have tested an example in GH actions and it works correctly for me, on the other hand if you want to compile it recommends you delete the files generated by your incorrect execution. You can also follow my answer in SO:https://stackoverflow.com/a/65568190/6622587

                          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                          Anton1978A 1 Reply Last reply
                          0
                          • eyllanescE eyllanesc

                            @Anton1978 It is very strange since I have tested an example in GH actions and it works correctly for me, on the other hand if you want to compile it recommends you delete the files generated by your incorrect execution. You can also follow my answer in SO:https://stackoverflow.com/a/65568190/6622587

                            Anton1978A Offline
                            Anton1978A Offline
                            Anton1978
                            wrote on last edited by
                            #14

                            @eyllanesc said in Unable to compile SQL plugin:

                            @Anton1978 It is very strange since I have tested an example in GH actions and it works correctly for me, on the other hand if you want to compile it recommends you delete the files generated by your incorrect execution. You can also follow my answer in SO:https://stackoverflow.com/a/65568190/6622587

                            This my question too)). The second day I am at war with this plugin.
                            Thanks for prompting me to git this plugin, it really helped, now it remains to figure out how to connect the compiled plugin to my QtCreator.

                            jsulmJ 1 Reply Last reply
                            0
                            • Anton1978A Anton1978

                              @eyllanesc said in Unable to compile SQL plugin:

                              @Anton1978 It is very strange since I have tested an example in GH actions and it works correctly for me, on the other hand if you want to compile it recommends you delete the files generated by your incorrect execution. You can also follow my answer in SO:https://stackoverflow.com/a/65568190/6622587

                              This my question too)). The second day I am at war with this plugin.
                              Thanks for prompting me to git this plugin, it really helped, now it remains to figure out how to connect the compiled plugin to my QtCreator.

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

                              @Anton1978 said in Unable to compile SQL plugin:

                              how to connect the compiled plugin to my QtCreator

                              You only need to call "make install" after make, then it should work.

                              It would be interesting to know why the preinstalled plug-in doesn't work. To do so set QT_DEBUG_PLUGINS=1 before starting your app. Then you should see what is happening.

                              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