64 bit Windows QT QPSQL driver
-
I am trying to remotely connect to a remote postgresql database and the database open tells me that QPSQL is not installed. I read other places that it is supposed to be included. Do I really have to download the entire source to build the driver or are they available for download?
-
Hi,
Which version of Qt are you using ?
Do you have the PostgreSQL client library installed on your system ?
-
I am using Qt 5.3.2
I just found this and am giving it a go
-
IIRC, Qt comes with the plugin built but you still need to first install the PostgreSQL client libraries.
-
What OS are you running ?
-
I am trying to build the driver with those instructions. I hate windows :(.
When I run mingw32-make I am trying to pass in the path to the postgresql includes as -I C:\Progra~iles\PostgreSQL\9.4\include where the include the make is complaining about libpq-fe.h is sitting. the make script can't find it.
-
Don't use backslashes but forward and you should quote the path since it contains spaces
-
I have done the following from this reference
http://doc.qt.io/qt-5/sql-driver.html#qpsql.
cd %QTDIR%\src\plugins\sqldrivers\psql
qmake "INCLUDEPATH+=C:/PostgreSQL/9.4/include" "LIBS+=C:/PostgreSQL/9.4/lib/libpq.lib" psql.pro
when I run make I get the error
ld.exe cannot find -llibpq.lib
-
Hi,
Try again with
@"LIBS+=-LC:/PostgreSQL/9.4/lib -lpq"@
-
That worked, thank you very much. Now I can't load it. Do I need to use the QPluginLoader or is there a way to enable it in the environment. I tried
QPLUGIN += qsqlpsql
I set the environment variable Q_DEBUG_PLUGINS to 1 and I see all that is loaded, byt the psql plugin does not show up.
-
Go the Run part of the Project panel and check that the PATH environment variable contains the path to the folder containing your PostgreSQL dlls
-
Sorry it took me so long to reply, I have been home sick all week. I just got it to the point where it seems like it should work.
If I make the call
db = QSqlDatabase::addDatabase("QPSQL");
the message shows:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7and the driver I am looking for seems to be in the list.
-
The driver is but your application also need to find the PostgreSQL dll(s) so the plugin can load
-
After 5 hours I'm obliged :) to give this contribution because otherwise it feels so wasted :). The reason, in my case, for above problem is that SSLEAY32.DLL and LIBEAY32.DLL dependency was MSVCR120.DLL which is part of the Visual studio 2013 redistributable with which Postgres for windows was built. Because those two files are dependencies of libpq.dll and libpq.dll is dependency of qsqlpsqld.dll hence the message.I downloaded and installed vcredist_x86.exe from http://www.microsoft.com/en-us/download/details.aspx?id=40784 and now it works. Although is maybe obious 32 bit version is needed, also great help was dependency walker, not at first but when I read 32 bit version of walker is needed everything was quite obvious.Hope it helps :)
-
Hi,
Thanks for sharing your findings !
-
I have to apologize that I haven't been able to check any of this. I will be back in the office tomorrow and will see where this is. I thought I had the postgresql lib directory on my path, but I really don't remember. The problem may be the microsoft redistributables, if infact I have the libs on my path.
I appreciate all of your help.