How get the Qt PostgreSQL plugin in ubuntu?
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.
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. 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? I lost hope, what else can I do? Its log after «export QT_DEBUG_PLUGINS = 1» https://cloud.mail.ru/public/3tnm/Zn2pjp1qr I installed Qt in the ‘home/myname/Qt’ folder But as I see the log now, there is an independent folder /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/ I didn’t create it. Now I run make in the ‘~/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers’ folder And got new errors:
anton@home:~/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers$ make sub-psql 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] Ошибка 1 make[1]: выход из каталога «/home/anton/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/psql» make: *** [Makefile:45: sub-psql] Ошибка 2
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) <>
Не решенные Steps of how to build QPSQL driver on linux(ubuntu 14.04)?
Hi,
i’m newbie to Qt. i wanted to interface Qt with postgresql database. i tried with this following code but failed to do that. Any help is appreciated..
QSqlDatabase mydb; mydb.addDatabase("QPSQL"); mydb.setHostName("192.168.2.24"); mydb.setDatabaseName("conf"); mydb.setUserName("postgres"); mydb.setPassword("cdt321"); mydb.setPort(5432); mydb.setConnectOptions(); if(mydb.open()) < qDebug() else
After Execution. I'm left with the Error message as follows Starting /run/user/0/gvfs/smb-share:server=main,share=data/Vijay/tableWidget/tableWidget.
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE
QSqlError(-1, "Driver not loaded", "Driver not loaded")
("QSQLITE") How to build QPSQL driver . i tried with many ways but failed . can anybody help me with the steps..
Yes, i do have libpq and libpd-dev files. and whats Qt installed from source?
Will you please brief about that? Thank you for the reply.
The following steps should get you going, you need the Qt sources (if you use the online installer just run it and also download the sources for the Qt version that you have already installed) PS: You do not need to build Qt from source, but you need the sources to build the plugin.
$ sudo apt-get install libpq-dev $ cd $QTDIR//Src/qtbase/src/plugins/sqldrivers/psql $ qmake "INCLUDEPATH+=/usr/include/postgresql" "LIBS+=-L/usr/lib -lpq" psql.pro $ make $ make install
After that is done check that the libqsqlpsql.so library is located in $QTDIR/
After running cd $QTDIR/3.0.1/Src/qtbase/src/plugins/sqldrivers/psql
its showing no such file or directory. and i think in dont have qtbase file..
@vIJI
You need to replace the $QTDIR with your actual path to Qt, so you end up with something like: /opt/Qt/5.4/Src/qtbase/src/plugins/sqldrivers/psql Also I am pretty sure that you should not have version 3.0.1 of Qt, that might be your version of QtCreator (not the same). Make sure where Qt was installed and what version of Qt you have. Perhaps run the following to see what version is installed:
qmake --version
This situation is a little bit strange.
I normally use PostgreSql with Qt (WIndows, Linux, Mac) without any problem.
In the Linux machine I only need the libpq5 and libpq-dev, and the Qt plugins directory.
@mrdebug
I always need to build the plugin myself. Do you install or build Qt yourself? Perhaps if you build it it detects that the pq libs are available and built the plugin automatically during the process.
Only in arm, in i386 I use the Qt official pachage.
Maybe the problem is the qt.conf file. Maybe the plugins directory is not in the correct position.