Cannot install postgreSQL driver



  • 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 file

    On 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?


  • Moderators

    @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?



  • Copied from the kits "Desktop Qt %{Qt:Version} MSVC2015 64bit" so yea msvc it seems


  • Moderators

    @paladinmain Did you install MSVC2015?



  • I have it installed, yes.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    To add to @jsulm, did you install the C++ components when installing VS2015 ? They are not selected by default.



  • Generally, you don't have to compile drivers for PostgreSQL.
    There are steps to use PostgreSQL:

    1. Add to your *.pro file this line:
    QT += sql
    
    1. 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).

    1. 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.



  • on 2. , do you mean to copy the sqldrivers to the folder where i'm compiling my project or?



  • @paladinmain
    Where your *.exe file will be. Something like this:

    .../ProjectRelease/project.exe
    .../ProjectRelease/sqldrivers/qsqlpsql.dll
    .../ProjectRelease/libpq.dll
    


  • 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?

    0_1499687136622_chess pro.jpg



  • 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.



  • @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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.