Cannot install postgreSQL driver
-
wrote on 9 Jul 2017, 23:53 last edited by
Hello! I'm posting here with the hopes that someone will be kind enough to help me. Just to clarify, I'm sort of a newb, so I'd be really grateful if you give more details to your explanations.
I'm on Windows 10 64 bit, QT 5.9.1, PostgreSQL is 9.6.3 version.
I'm working on a project, where I need to get a postgresql database running and connect it to the code I'm doing right now. Unfortunately, when I try to install the driver, I run into all kinds of problems. I've been reading on threads on sites, but they are outdated and some folders do not match, which my first problem arises. For some reason I cannot get qmake to work, even though I edit the path in the variables.
I tried running the commands from here.
cd %QTDIR%\qtbase\src\plugins\sqldrivers\psql
qmake "INCLUDEPATH+=C:/psql/include" "LIBS+=C:/psql/lib/ms/libpq.lib" psql.pro
nmake
Basically my folders don't aren't 100% as the guide, also I don't have a libpq.lib fileOn my final attempt I tried the following:
qmake "INCLUDEPATH+=C:/PostgreSQL/pg96/include" "LIBS+=C:/PostgreSQL/pg96/lib/libpq.lib"
Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment? -
Hello! I'm posting here with the hopes that someone will be kind enough to help me. Just to clarify, I'm sort of a newb, so I'd be really grateful if you give more details to your explanations.
I'm on Windows 10 64 bit, QT 5.9.1, PostgreSQL is 9.6.3 version.
I'm working on a project, where I need to get a postgresql database running and connect it to the code I'm doing right now. Unfortunately, when I try to install the driver, I run into all kinds of problems. I've been reading on threads on sites, but they are outdated and some folders do not match, which my first problem arises. For some reason I cannot get qmake to work, even though I edit the path in the variables.
I tried running the commands from here.
cd %QTDIR%\qtbase\src\plugins\sqldrivers\psql
qmake "INCLUDEPATH+=C:/psql/include" "LIBS+=C:/psql/lib/ms/libpq.lib" psql.pro
nmake
Basically my folders don't aren't 100% as the guide, also I don't have a libpq.lib fileOn my final attempt I tried the following:
qmake "INCLUDEPATH+=C:/PostgreSQL/pg96/include" "LIBS+=C:/PostgreSQL/pg96/lib/libpq.lib"
Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment?@paladinmain It looks like you're using Visual C++ compiler, is this correct? You not provide this information. So, which exact compiler and Qt version do you use?
-
wrote on 10 Jul 2017, 08:27 last edited by
Copied from the kits "Desktop Qt %{Qt:Version} MSVC2015 64bit" so yea msvc it seems
-
Copied from the kits "Desktop Qt %{Qt:Version} MSVC2015 64bit" so yea msvc it seems
@paladinmain Did you install MSVC2015?
-
wrote on 10 Jul 2017, 09:19 last edited by
I have it installed, yes.
-
Hi and welcome to devnet,
To add to @jsulm, did you install the C++ components when installing VS2015 ? They are not selected by default.
-
wrote on 10 Jul 2017, 09:48 last edited by Stoyan 7 Oct 2017, 09:50
Generally, you don't have to compile drivers for PostgreSQL.
There are steps to use PostgreSQL:- Add to your *.pro file this line:
QT += sql
- Copy to the folder with your application (exe) this folder:
%QTDIR%\plugins\sqldrivers
Especially files "qsqlpsql.dll" (for Release) and/or "qsqlpsqld.dll" (for Debug).
3. Copy to the folder with your application (exe) this files from PostgreSQL folder:libeay32.dll libiconv-2.dll libintl-8.dll libpq.dll ssleay32.dll
You can get them from zip archive of the binaries if you don't want to install PostgreSQL.
Note that you will need files for the same system version like your Qt version.
For example:
If you use MinGW32 (witch is only 32-bit) or MSVC x32 you need these files from 32-bit version of PostgreSQL.
If you use MSVC x64 you need these files from 64-bit version of PostgreSQL. -
wrote on 10 Jul 2017, 10:37 last edited by
on 2. , do you mean to copy the sqldrivers to the folder where i'm compiling my project or?
-
on 2. , do you mean to copy the sqldrivers to the folder where i'm compiling my project or?
wrote on 10 Jul 2017, 11:05 last edited by@paladinmain
Where your *.exe file will be. Something like this:.../ProjectRelease/project.exe .../ProjectRelease/sqldrivers/qsqlpsql.dll .../ProjectRelease/libpq.dll
-
wrote on 10 Jul 2017, 11:48 last edited by paladinmain 7 Oct 2017, 11:49
-
wrote on 10 Jul 2017, 13:43 last edited by
Just a small update.
I just gave up. Installed qt and postgresql on ubuntu and compiled the project with no problems. Guess I'll be finishing it on Ubuntu. Thanks for all the replies, guys.
-
Thanks for the quick replies.
I copied the dlls and the sqldrivers in the .pro folder and added the QT += sql in the .pro file. Did you mean to put them into the folder like that?
wrote on 10 Jul 2017, 15:00 last edited by@paladinmain
No. This is wrong folder.
Look one level up -> (for example) chess-game-Release\release
Or look from Qt Creator:
Projects -> Build Settings -> Build directory
10/12