QPSQL Driver Not found (Qt 5.5.1 & PostgreSQL 9.5)
-
I have followed the instructions from this link:
http://doc.qt.io/qt-5/sql-driver.htmlI am using the Qt 5.5 for Desktop (MinGW 4.9.2 32 bit)
**Unfortunately I get error with many undefined references: **C:\Qt\5.5\Src\qtbase\src\plugins\sqldrivers\psql>qmake "INCLUDEPATH+=C:\Po
QL\include" "LIBS+=C:\PostgreSQL\lib\libpq.lib" psql.proC:\Qt\5.5\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory 'C:/Qt/5.5/Src/qtbase/src/plugins/sqld
/psql'
C:\Qt\5.5\mingw492_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_
ROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_C
B -D__GNUC__ -DWIN32 -IC:/Qt/5.5/Src/qtbase/mkspecs/win32-g++ -IC:/Qt/5.5/
base/src/plugins/sqldrivers/psql -IC:/Utils/icu32_54_1_mingw492/include -I
nssl/include -IC:/utils/postgresql/pgsql/include -IC:/PostgreSQL/include -
/5.5/mingw492_32/include/QtCore/5.5.1 -IC:/Qt/5.5/mingw492_32/include/QtCo
.1/QtCore -IC:/Qt/5.5/mingw492_32/include/QtSql/5.5.1 -IC:/Qt/5.5/mingw492
clude/QtSql/5.5.1/QtSql -IC:/Qt/5.5/mingw492_32/include -IC:/Qt/5.5/mingw4
include/QtSql -IC:/Qt/5.5/mingw492_32/include/QtCore main.cpp -o .moc\rele
in.moc
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -fr
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_N
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -IC:/Utils
54_1_mingw492/include -IC:/openssl/include -IC:/utils/postgresql/pgsql/in
-IC:\PostgreSQL\include -IC:\Qt\5.5\mingw492_32\include\QtCore\5.5.1 -IC:
\mingw492_32\include\QtCore\5.5.1\QtCore -IC:\Qt\5.5\mingw492_32\include\Q
.5.1 -IC:\Qt\5.5\mingw492_32\include\QtSql\5.5.1\QtSql -IC:\Qt\5.5\mingw49
nclude -IC:\Qt\5.5\mingw492_32\include\QtSql -IC:\Qt\5.5\mingw492_32\inclu
ore -I.moc\release -I........\mkspecs\win32-g++ -o .obj\release\main.o
cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -fr
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_N
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -IC:/Utils
54_1_mingw492/include -IC:/openssl/include -IC:/utils/postgresql/pgsql/in
-IC:\PostgreSQL\include -IC:\Qt\5.5\mingw492_32\include\QtCore\5.5.1 -IC:
\mingw492_32\include\QtCore\5.5.1\QtCore -IC:\Qt\5.5\mingw492_32\include\Q
.5.1 -IC:\Qt\5.5\mingw492_32\include\QtSql\5.5.1\QtSql -IC:\Qt\5.5\mingw49
nclude -IC:\Qt\5.5\mingw492_32\include\QtSql -IC:\Qt\5.5\mingw492_32\inclu
ore -I.moc\release -I........\mkspecs\win32-g++ -o .obj\release\qsql_p
......\sql\drivers\psql\qsql_psql.cpp
In file included from C:\Qt\5.5\mingw492_32\include/QtCore/qregexp.h:41:0,
from C:\Qt\5.5\mingw492_32\include/QtCore/qstringlist.h:4
from C:\Qt\5.5\mingw492_32\include/QtCore/qlist.h:1026,
from C:\Qt\5.5\mingw492_32\include/QtCore/qvariant.h:39,
from C:\Qt\5.5\mingw492_32\include/QtSql/qsqlresult.h:37,
from ......\sql\drivers\psql\qsql_psql_p.h:48,
from ......\sql\drivers\psql\qsql_psql.cpp:34:
C:\Qt\5.5\mingw492_32\include/QtCore/qstring.h: In member function 'virtua
iant QPSQLResult::data(int)':
C:\Qt\5.5\mingw492_32\include/QtCore/qstring.h:969:47: warning: assuming s
overflow does not occur when assuming that (X - c) <= X is always true [-W
-overflow]
{ return i < s.d->size ? s.d->data()[i] : 0; }
^
C:\Qt\5.5\mingw492_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO
ROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_C
B -D__GNUC_ -DWIN32 -IC:/Qt/5.5/Src/qtbase/mkspecs/win32-g++ -IC:/Qt/5.5/
base/src/plugins/sqldrivers/psql -IC:/Utils/icu32_54_1_mingw492/include -I
nssl/include -IC:/utils/postgresql/pgsql/include -IC:/PostgreSQL/include -
/5.5/mingw492_32/include/QtCore/5.5.1 -IC:/Qt/5.5/mingw492_32/include/QtCo
.1/QtCore -IC:/Qt/5.5/mingw492_32/include/QtSql/5.5.1 -IC:/Qt/5.5/mingw492
clude/QtSql/5.5.1/QtSql -IC:/Qt/5.5/mingw492_32/include -IC:/Qt/5.5/mingw4
include/QtSql -IC:/Qt/5.5/mingw492_32/include/QtCore ......\sql\drivers
sql_psql_p.h -o .moc\release\moc_qsql_psql_p.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -fr
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_N
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -IC:/Utils
_54_1_mingw492/include -IC:/openssl/include -IC:/utils/postgresql/pgsql/in
-IC:\PostgreSQL\include -IC:\Qt\5.5\mingw492_32\include\QtCore\5.5.1 -IC:
\mingw492_32\include\QtCore\5.5.1\QtCore -IC:\Qt\5.5\mingw492_32\include\Q
.5.1 -IC:\Qt\5.5\mingw492_32\include\QtSql\5.5.1\QtSql -IC:\Qt\5.5\mingw49
nclude -IC:\Qt\5.5\mingw492_32\include\QtSql -IC:\Qt\5.5\mingw492_32\inclu
ore -I.moc\release -I........\mkspecs\win32-g++ -o .obj\release\moc_qs
l_p.o .moc\release\moc_qsql_psql_p.cpp
windres -i qsqlpsql_resource.rc -o .obj\release\qsqlpsql_resource_res.o --
e-dir=. -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EX
NS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB
g++ -Wl,-s -shared -Wl,-subsystem,windows -Wl,--out-implib,C:\Qt\5.5\Src\q
plugins\sqldrivers\libqsqlpsql.a -o ........\plugins\sqldrivers\qsqlpsq
.obj/release/main.o .obj/release/qsql_psql.o .obj/release/moc_qsql_psql_p.
PostgreSQL\lib\libpq.lib -L C:/utils/postgresql/pgsql/lib -LC:/Qt/5.5/ming
2/lib -lQt5Sql -lQt5Core .obj\release\qsqlpsql_resource_res.o
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x176): undefined reference
ntuples'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x227): undefined reference
getvalue'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x23e): undefined reference
getisnull'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x42e): undefined reference
cmdTuples'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x6c1): undefined reference
oidValue'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x76f): undefined reference
errorMessage'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x7c5): undefined reference
resultErrorField'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xb4b): undefined reference
nfields'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xb9a): undefined reference
fname'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xc0a): undefined reference
ftype'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xc2e): undefined reference
fsize'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xc41): undefined reference
fmod'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xd52): undefined reference
fname'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xdf1): undefined reference
nfields'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xe04): undefined reference
ftype'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xe35): undefined reference
getvalue'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0xe59): undefined reference
getisnull'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x11a4): undefined reference
QunescapeBytea'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x11c4): undefined reference
Qfreemem'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x17cd): undefined reference
Qexec'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x19e2): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x19f2): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x1a34): undefined reference
Qgetvalue'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x1afd): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x1c3d): undefined reference
Qntuples'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x1cdc): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x1cf4): undefined reference
QerrorMessage'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x1d3d): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x2015): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x232a): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x2334): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x236c): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x237c): undefined reference
QerrorMessage'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x23c5): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x240e): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x2427): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x2484): undefined reference
Qgetvalue'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x27f1): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x290b): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x2d1a): undefined reference
Qfinish'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3184): undefined reference
Qconnectdb'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x31b9): undefined reference
Qstatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x34cc): undefined reference
Qfinish'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3588): undefined reference
Qfinish'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3636): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x36e1): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3744): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x37cb): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x37e1): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3881): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3904): undefined reference
QcmdStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3966): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3a11): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x3a74): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x553d): undefined reference
Qstatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x5609): undefined reference
QconsumeInput'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x5617): undefined reference
Qnotifies'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x56f8): undefined reference
QbackendPID'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x576a): undefined reference
Qfreemem'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x6017): undefined reference
Qsocket'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x60fb): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x65b3): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x6a4f): undefined reference
QresultStatus'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x6b08): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x6cb9): undefined reference
Qclear'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x74d7): undefined reference
QescapeByteaConn'
.obj/release/qsql_psql.o:qsql_psql.cpp:(.text+0x758f): undefined reference
Qfreemem'
C:/Qt/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../
64-mingw32/bin/ld.exe: .obj/release/qsql_psql.o: bad reloc address 0x0 in
n `.rdata'
collect2.exe: error: ld returned 1 exit status
Makefile.Release:81: recipe for target '........\plugins\sqldrivers\qsq
dll' failed
mingw32-make[1]: *** [........\plugins\sqldrivers\qsqlpsql.dll] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/5.5/Src/qtbase/src/plugins/sqldr
psql'
makefile:38: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2Any help or pointers are greatly appreciated . Many thanks!
-
Hi and welcome to devnet,
Two things comes to mind:
- Is your PostgreSQL build for MinGW ?
- If it is, is it the correct architecture ?
-
Hi!
Thanks for the welcome and the response!
I am new to Qt and find it amazing and look forward to setting up database programming environment on it. Just re-installed Qt but now QT5.6 along with 5.5 & 5.4 MinGW491&492 and I am running the SQL Browser example to learn how to connecct with a DB.
(Still the same error:
An error occured while opening the connection: Driver not loaded Driver not loaded.
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7- I have installed PostgreSQL without the MinGW build i.e. have done it with windows installer (have made a small db and its working). Have windows8.1 os on x64 platform.
- Have also installed MSSQL Management Studio/MSQL Server-2014 express to connect it with Qt and I still get the following error
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 - Followed the video here to solve how-to connect with the Postgres, but no 'go'
- After installing Qt5.6 , checked the folder "C:\Qt\5.6\mingw49_32\plugins\sqldrivers" and it doesn't have:
- qsqlodbc.dll
- qsqlodbcd.dll
unlike it did when It was Qt5.5
-
One of the important things is to modify your PATH environment variable in Qt Creator in order for your application to find the PostgreSQL DLLs and thus allow the plugin to be loaded.
-
@SGaist said:
PATH environment variable in Qt Creator
I added the paths:
C:\Qt\5.6\mingw49_32\plugins\sqldrivers;C:\Qt\5.6\Src\qtbase\plugins\sqldrivers;C:\Qt\5.6\Src\qtbase\src\plugins\sqldrivers;
to the PATH variable in the Build Environment. It remains unsaved as it shows itself up in Bold font.
it seems quite basic here but got me stuck.PATH = C:\Qt\5.6\mingw49_32\plugins\sqldrivers;C:\Qt\5.6\Src\qtbase\plugins\sqldrivers;C:\Qt\5.6\Src\qtbase\src\plugins\sqldrivers; :${PATH}
Something I miss here, as it won't append. Please help me out. -
Got this Errror:
Got keys from plugin meta data ("svg", "svgz", "svg.gz")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Examples/Qt-5.6/qtbase/sql/build-sqlbrowser-Desktop_Qt_5_6_0_MinGW_32bit-Debug/debug/iconengines" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/5.6/mingw49_32/plugins/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Examples/Qt-5.6/qtbase/sql/build-sqlbrowser-Desktop_Qt_5_6_0_MinGW_32bit-Debug/debug/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/5.6/mingw49_32/plugins/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt/Examples/Qt-5.6/qtbase/sql/build-sqlbrowser-Desktop_Qt_5_6_0_MinGW_32bit-Debug/debug/accessiblebridge" ...
loaded library "C:/Qt/5.6/mingw49_32/plugins/sqldrivers/qsqlpsqld.dll"
QLibraryPrivate::loadPlugin failed on "C:/Qt/5.6/mingw49_32/plugins/sqldrivers/qsqlpsqld.dll" : "Cannot load library C:\Qt\5.6\mingw49_32\plugins\sqldrivers\qsqlpsqld.dll: The specified module could not be found."
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7-
Ran Dependency Walker on "qsqlpsqld.dll" and the dependencies are as follow:
LIBSTDC++-6.DLL
QTSCORED.DLL
QTSSQLD.DLL
LIBPQ.DLL -
Have added to the PATH "C:/Qt/5.6/mingw49_32/plugins/sqldrivers/" "C:\Qt\5.6\mingw49_32\bin"
-
Have already copied "libpq.dll" in the "C:\Qt\5.6\mingw49_32\bin" folder along with "libeay32.dll", "libintl-8.dll", "libpq.dll" and "ssleay32.dll"
-
-
You don't need to any Qt related path to PATH. By the way, are you doing it in the Build part ? That should go in the Run part.
Also there's no need to copy libpq.dll around, just add the folder that contains it to PATH.
One thing you can do to verify that everything is fine with that .DLL is to run Dependency Walker and add the path to the libqp.dll folder in the search path list. It should show you if there's something wrong with it.
-
When I go to the run part it shows that Base environment for this run configuration = the build environment.
The path to "LIBPQ.DLL" already exists here.**add the path to the libqp.dll folder in the search path list
**Can you elaborate this? If you say this is done in Dependency Walker then I can't find the search path list to add the path.
I already ran Dependency Walker on "qsqlpsqld.dll" and found 4 dependencies. -
Right, I forgot that by default the build environment is copied including your customizations.
In Dependency Walker, there's a menu (I don't remember its name right now) that allows you to customize the list of paths search for dependencies of what you are currently analyzing. There you can add the path to PostgreSQL .dll files.
-
Yes, that's that one.