Deploy application in windows with driver of postgresql
-
Hi,
Everything works fine on my PC, I can connect to the postgresql driver.
I have developed an application with c ++ and some files in qml, which connect to a postgresql database.
I have compiled my executable with mingw73_64, which is what brings the installation of Qt 5.12.1.
From my PC, I have tried to connect to a database that is regardless of the architecture, that is, I connect to a 32-bit postgresql 9.2 database, and a 64-bit postgresql 11 database, and everything works.
When I try to deploy my application to be used on other PCs, I use this:windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
which is how it comes in the description of my qt. This generates all the dll associated with my application, but those of postgres are missing, so I have copied the following libraries found in the postgres installation:
for 64 bit
libeay32.dll
libiconv-2.dll
libintl-9.dll
libpq.dll
libxml2.dll
libxslt.dll
ssleay32.dll
zlib1.dllor for 32 bit, in case I connect to the 32 bit postgres database
libeay32.dll
libintl.dll
libpq.dll
ssleay32.dllWhen I try to put these files on another PC, I get a driver not loaded error.
and I have the postgres dll files mentioned, I have the sqldrivers folder with its qsqlpsql.dll dll, but it doesn't work for me.
I tried with different dll but I don't get it.
I tried to create my own library as it says in the version of qtcd% QTDIR% \ qtbase \ src \ plugins \ sqldrivers
qmake - "PSQL_INCDIR = C: \ Program Files \ PostgreSQL \ 11 \ include" PSQL_LIBDIR = "C: \ Program Files \ PostgreSQL \ 11 \ lib \ ms"
nmake sub-psqlbut when doing the qmake from the console of Qt 5.12.1 (MinGW7.3.0 64 bit)
I am shown a list of the sql drivers but only those of SQLITE and ODBC are activated, but that of postgresql is not.
What could be the problem that does not connect on other PCs, and on mine if it connects?
-
Use Dependency Walker or similar to find out what the Qt postgres plugin really needs.
-
Hi,
Beside the good advice from @Christian-Ehrlicher, check also the PostgreSQL libraries dependencies.
-
Maybe a question of the architecture of the dll you copied.
By the way, unless you added the folder containing the .dll in the search path of Dependency Walker, it will not find it because the plugin is in a different folder.
-
Before to update this programn, its work Fine with dlls of postgresql for 32 bit. This change could be the problem when i try to compile my programn, but this time with 64 bit?
-
I get it.
But the version of Qt 5.12.1 comes for 64 bit, and what it has done is compile everything to 64bit, with windeploy it takes all 64 bit dll.
The application works for me, it starts, but the first thing I have is a login form, and when I try to use it, it gives me the driver not loaded error. That is why I think it is the postgres libraries that should be giving me problems. -
I get it.
But the version of Qt 5.12.1 comes for 64 bit, and what it has done is compile everything to 64bit, with windeploy it takes all 64 bit dll.
The application works for me, it starts, but the first thing I have is a login form, and when I try to use it, it gives me the driver not loaded error. That is why I think it is the postgres libraries that should be giving me problems. -
on the pc that I have the database,
I have 2 versions of postgres installed, 9.2 of 32 bit, and 11 of 64 bit. I have stopped the postgresql service of the 32-bit one, in case they conflict. I have copied the dll that are in the bin folder of version 11 of 64 bit postgres, for my program folder and it still gives me the same error of
"Driver not load" -
Again: are you sure that the correct dependencies are found ?
-
Hello,
I have solved with the dependency walker tool,
as advised by @Christian Ehrlicher and @SGaist.
It was not a problem of the postgres dll but it was necessary to install mvcredistx64.