Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot install postgreSQL driver

Cannot install postgreSQL driver

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 9.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P paladinmain

    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?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

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

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • P Offline
      P Offline
      paladinmain
      wrote on last edited by
      #3

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

      jsulmJ 1 Reply Last reply
      0
      • P paladinmain

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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @paladinmain Did you install MSVC2015?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • P Offline
          P Offline
          paladinmain
          wrote on last edited by
          #5

          I have it installed, yes.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Hi and welcome to devnet,

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Stoyan
              wrote on last edited by Stoyan
              #7

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

              1 Reply Last reply
              3
              • P Offline
                P Offline
                paladinmain
                wrote on last edited by
                #8

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

                S 1 Reply Last reply
                0
                • P paladinmain

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

                  S Offline
                  S Offline
                  Stoyan
                  wrote on last edited by
                  #9

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

                  .../ProjectRelease/project.exe
                  .../ProjectRelease/sqldrivers/qsqlpsql.dll
                  .../ProjectRelease/libpq.dll
                  
                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    paladinmain
                    wrote on last edited by paladinmain
                    #10

                    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

                    S 1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      paladinmain
                      wrote on last edited by
                      #11

                      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.

                      1 Reply Last reply
                      0
                      • P paladinmain

                        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

                        S Offline
                        S Offline
                        Stoyan
                        wrote on last edited by
                        #12

                        @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

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved