Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Installing PostgreSQL on Qt 5.15/PostgreSQL 12/Windows 10
Forum Updated to NodeBB v4.3 + New Features

Installing PostgreSQL on Qt 5.15/PostgreSQL 12/Windows 10

Scheduled Pinned Locked Moved Solved Installation and Deployment
17 Posts 3 Posters 4.1k Views 2 Watching
  • 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.
  • L Offline
    L Offline
    Laplace
    wrote on 26 Jun 2020, 15:33 last edited by Laplace
    #8

    I'm sorry to say I am still having trouble. The compiling the drivers is now fine, but I am having trouble when it comes to actually using them.

    From my applications log:

     QFactoryLoader::QFactoryLoader() looking at "C:/Qt/5.15.0/msvc2019_64/plugins/sqldrivers/qsqlpsqld.dll"
     Found metadata in lib C:/Qt/5.15.0/msvc2019_64/plugins/sqldrivers/qsqlpsqld.dll, metadata=
     {
         "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
         "MetaData": {
             "Keys": [
                 "QPSQL7",
                 "QPSQL"
             ]
         },
         "archreq": 1,
         "className": "QPSQLDriverPlugin",
         "debug": true,
         "version": 331520
     }
     
     
     Got keys from plugin meta data ("QPSQL7", "QPSQL")
    

    So this is the actual debug plugin. The metadata looks good.

     Module loaded: C:\Qt\5.15.0\msvc2019_64\plugins\sqldrivers\qsqlpsqld.dll
    

    So it was able to load the DLL for the plugin...

     Cannot load library C:\Qt\5.15.0\msvc2019_64\plugins\sqldrivers\qsqlpsqld.dll: The specified module could not be found.
    

    But then failed to load it!

    It seems that some deps of qsqlpsqld.dll is failing to load. I checked dependency walker (this rewrite specifically) and LIBPQ.dll was missing. This DLL is located in C:\Program Files\PostgreSQL\12\lib which should have been included (or linked?) when building the plugin!

    After copying LIBPQ.dll to the plugin folder, the following were missing:

    libcrypto-1_1-x64.dll
    libssl-1_1-x64.dll
    libintl-8.dll
    WS2_32.dll
    WLDAP32.dll
    

    The first two are from OpenSSL, the last two are from Windows and finally libintl-8.dll seems to be from PostgreSQL itself.

    Here is the nmake log (here).

    I installed OpenSSL (using this installer). Installing this and fixed those two dependencies.

    I'm assuming WS2_32.dll and WLDAP32.dll are not causing the issue.

    So I'm stuck at libintl-8.dll: this is a PostreSQL lib, but in C:\Program Files\PostgreSQL\12\lib all I have is libintl.lib. My understanding of these things is limited, but I believe that libintl.lib is a static library, so wouldn't the compilation process of the plugin need to generate the above referenced DLL (libintl-8.dll)? Or where is the reference to libintl-8.dll coming from?

    Is there a way to avoid this hassle altogether by telling qmake or namke "just build/copy all of the required dependencies to C:\Qt\5.15.0\msvc2019_64\plugins\sqldrivers when you build"?

    1 Reply Last reply
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 26 Jun 2020, 15:38 last edited by
      #9

      @Laplace said in Installing PostgreSQL on Qt 5.15/PostgreSQL 12/Windows 10:

      "just build/copy all of the required dependencies to C:\Qt\5.15.0\msvc2019_64\plugins\sqldrivers when you build"?

      No, you have to take care for your deps by yourself with e.g. Dependency Walker.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      L 1 Reply Last reply 26 Jun 2020, 15:51
      1
      • C Christian Ehrlicher
        26 Jun 2020, 15:38

        @Laplace said in Installing PostgreSQL on Qt 5.15/PostgreSQL 12/Windows 10:

        "just build/copy all of the required dependencies to C:\Qt\5.15.0\msvc2019_64\plugins\sqldrivers when you build"?

        No, you have to take care for your deps by yourself with e.g. Dependency Walker.

        L Offline
        L Offline
        Laplace
        wrote on 26 Jun 2020, 15:51 last edited by
        #10

        @Christian-Ehrlicher said in [Installing PostgreSQL on Qt 5.15/PostgreSQL

        No, you have to take care for your deps by yourself with e.g. Dependency Walker.

        Good to know at least that I am doing things the right way!

        I was able to find libintl-8.dll in C:\Program Files\PostgreSQL\12\bin.

        Still unable to load the plugin. It seems that WS2_32.dll and WLDAP32.dll are causing issues. These are Windows libraries. Googling reveals pretty generic results. If anyone has any ideas, I'd appreciate the input.

        1 Reply Last reply
        0
        • C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 26 Jun 2020, 15:52 last edited by
          #11

          I would check if the correct msvc runtime is installed on the target pc. Afair it needs the ones from msvc2015. But don't remember exactly.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Laplace
            wrote on 26 Jun 2020, 16:02 last edited by Laplace
            #12

            I was able to resolve things!

            Here were the required dependencies:

            • libcrypto-1_1-x64.dll: from OpenSSL install.
            • libssl-1_1-x64.dll: from OpenSSL install.
            • libpq.dll: from C:\Program Files\PostgreSQL\12\lib
            • libintl-8.dll: from C:\Program Files\PostgreSQL\12\bin
            • libiconv-2.dll: from C:\Program Files\PostgreSQL\12\bin

            I first copied them manually to the same folder as my .exe, along with the actual plugin DLLs (qsqlpsql.dll). That worked.

            Next I tried using windqtdeploy. It actually was able to detect all of them, but it copied them to a folder called sqldrivers which is a subdirectory of the folder my .exe is in. That did not work. I had to manually copy the following from the sqldrivers subdirectory to the main directory:

            • libpq.dll
            • libintl-8.dll
            • libiconv-2.dll

            Is there any way to tell windqtdeploy to copy these DLLs to the .exe folder instead of the subfolder, hence avoiding one more manual step?

            1 Reply Last reply
            1
            • C Online
              C Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 26 Jun 2020, 16:20 last edited by
              #13

              @Laplace said in Installing PostgreSQL on Qt 5.15/PostgreSQL 12/Windows 10:

              Is there any way to tell windqtdeploy to copy these DLLs to the .exe folder instead of the subfolder

              No but they should be in the same dir as the plugin so it's strange - maybe you have some of those libs (with other version) in your PATH?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              L 1 Reply Last reply 26 Jun 2020, 16:31
              0
              • C Christian Ehrlicher
                26 Jun 2020, 16:20

                @Laplace said in Installing PostgreSQL on Qt 5.15/PostgreSQL 12/Windows 10:

                Is there any way to tell windqtdeploy to copy these DLLs to the .exe folder instead of the subfolder

                No but they should be in the same dir as the plugin so it's strange - maybe you have some of those libs (with other version) in your PATH?

                L Offline
                L Offline
                Laplace
                wrote on 26 Jun 2020, 16:31 last edited by
                #14

                @Christian-Ehrlicher said in [Installing PostgreSQL on Qt 5.15/PostgreSQL

                No but they should be in the same dir as the plugin so it's strange - maybe you have some of those libs (with other version) in your PATH?

                I don't think so because (1) I checked my PATH and didn't see anything and (2) I don't have any other versions of PostgreSQL intalled or anything like that.

                C 1 Reply Last reply 26 Jun 2020, 16:46
                0
                • L Laplace
                  26 Jun 2020, 16:31

                  @Christian-Ehrlicher said in [Installing PostgreSQL on Qt 5.15/PostgreSQL

                  No but they should be in the same dir as the plugin so it's strange - maybe you have some of those libs (with other version) in your PATH?

                  I don't think so because (1) I checked my PATH and didn't see anything and (2) I don't have any other versions of PostgreSQL intalled or anything like that.

                  C Online
                  C Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 26 Jun 2020, 16:46 last edited by
                  #15

                  @Laplace Ok, then I'll accept it the way it is - no time to look further why it doesn't work like it should :)

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Laplace
                    wrote on 26 Jun 2020, 16:51 last edited by
                    #16

                    Alternatively: can I add the sqldrivers folder to the top of the current session (or whatever these are called in Window's)? So something equivalent to:

                    set "PATH=%cd%\sqldrivers;%PATH%"
                    myapp.exe
                    

                    But done automatically when double clicking the .exe.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Laplace
                      wrote on 26 Jun 2020, 17:28 last edited by
                      #17

                      This did the trick:

                      #ifdef Q_OS_WIN
                          // Add the sqldrivers folder to path
                          QDir app_dir(QApplication::applicationDirPath());
                          QString path;
                          path = app_dir.absolutePath();
                          path = path + "/sqldrivers";
                          path = QStringLiteral("%1;%2").arg(path).arg(QString(qgetenv("PATH")));
                          qputenv("PATH", path.toUtf8());
                      #endif
                      
                      1 Reply Last reply
                      0

                      17/17

                      26 Jun 2020, 17:28

                      • Login

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