Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPSQL driver not loaded even though QPSQL driver is available
Qt 6.12 LTS is out! See what's new in the release blog

QPSQL driver not loaded even though QPSQL driver is available

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 21.6k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I am using Qt 4.8.2 to build a desktop app on linux that connects to a PostgreSQL database running in the background. I have build and installed the QPSQL driver. When I try to establish a connection to the database , I get the "Driver Not Loaded, Driver Not Loaded " error , even though QSqlDatabase reports that "QPSQL" is available. Here is my code :

    @ QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("localhost");
    db.setDatabaseName("demo");
    db.setUserName("root");
    db.setPassword("ET_DIAGDB_CONTROL");
    db.setPort(5432);

    @

    on running the code , I get the following error:

    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL3 QMYSQL QODBC3 QODBC QPSQL7 QPSQL

    I have checked that libqslqpsql.so is present in my plugins/sqldrivers directory and i have included the path to that directory in my paths

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MementoMori
      wrote on last edited by
      #2

      in the executable's path make sure you have the following files (I suppose you're using windows):

      comerr32.dll
      gssapi32.dll
      k5sprt32.dll
      krb5_32.dll
      libgcc_s_dw2-1.dll
      libiconv-2.dll
      libintl-8.dll
      libpq.dll
      mingwm10.dll
      msvcr71.dll

      you may also need:

      libssl32.dll
      libeay32.dll
      ssleay32.dll

      HTH

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I am on linux

        1 Reply Last reply
        0
        • I Offline
          I Offline
          issam
          wrote on last edited by
          #4

          libpq.so.5 is (yum install PostgreSQL-libs) necessary for g++ to link the executable (Remember that in a Linux environment shared libraries have the extension .so not .dll).

          In the other hand, may be, there are some lines that you must add to your pro file (qMakefile):

          The variables accessible with this operator are typically used to enable third party plugins and components to be integrated with Qt. For example, a Qt Designer plugin can be installed alongside Qt Designer's built-in plugins if the following declaration is made in its project file:

          @
          target.path = $$[QT_INSTALL_PLUGINS]/designer
          INSTALLS += target
          @

          See in the documentation: qmake Advanced Usage

          good luck :)

          http://www.iissam.com/

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MementoMori
            wrote on last edited by
            #5

            in linux you should use ldd to find the dependencies of an executable/shared object

            for example:

            @
            $ ldd libqsqlpsql.so
            linux-gate.so.1 => (0xb77c4000)
            libpq.so.5 => /usr/lib/libpq.so.5 (0xb7770000)
            libQtSql.so.4 => /home/filippo/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtSql.so.4 (0xb7730000)
            libQtCore.so.4 => /home/filippo/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtCore.so.4 (0xb7448000)
            libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb7363000)
            libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb7345000)
            libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb71a0000)
            ...

            @

            man ldd for further details.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Thanks! Idd told me that libpq.so.5 was missing. I included it in my LD_LIBRARY_PATH and it works now .

              1 Reply Last reply
              0
              • I Offline
                I Offline
                issam
                wrote on last edited by
                #7

                good

                http://www.iissam.com/

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