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. QPSQL driver cannot be loaded
Forum Updated to NodeBB v4.3 + New Features

QPSQL driver cannot be loaded

Scheduled Pinned Locked Moved Unsolved General and Desktop
sqlqpsqlqt 5.1532bitmingw
3 Posts 2 Posters 357 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.
  • K Offline
    K Offline
    KK2022
    wrote on last edited by
    #1

    Hello,
    I am combing through the forums and information on the internet to find a solution.
    I am trying to run the following code on my Windows 11 PC with Qt 5.15 Mingw 32 Bit compiler.

        m_db = QSqlDatabase::addDatabase("QPSQL");
        m_db.setHostName("192.168.112.70");
        m_db.setDatabaseName("myDB");
        m_db.setUserName("user");
        m_db.setPassword("pwd");
    
        qDebug() << "Available Drivers: " << QSqlDatabase::drivers();
    
        if (!m_db.open()) {
            qDebug() << "Failed to connect to database:" << m_db.lastError().text();
        }
    

    I get the following debug information with QT_DEBUG_PLUGINS=1

    QFactoryLoader::QFactoryLoader() looking at "C:/Qt/5.15.2/mingw81_32/plugins/sqldrivers/qsqlpsql.dll"
    Found metadata in lib C:/Qt/5.15.2/mingw81_32/plugins/sqldrivers/qsqlpsql.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
                "QPSQL7",
                "QPSQL"
            ]
        },
        "archreq": 0,
        "className": "QPSQLDriverPlugin",
        "debug": false,
        "version": 331520
    }
    
    Got keys from plugin meta data ("QPSQL7", "QPSQL")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/user/Documents/Qt_Projects/display-software/build/Desktop_Qt_5_15_2_MinGW_32_bit-Debug/debug/sqldrivers" ...
    Cannot load library C:\Qt\5.15.2\mingw81_32\plugins\sqldrivers\qsqlpsql.dll: Unknown error 0x000000c1.
    QLibraryPrivate::loadPlugin failed on "C:/Qt/5.15.2/mingw81_32/plugins/sqldrivers/qsqlpsql.dll" : "Cannot load library C:\\Qt\\5.15.2\\mingw81_32\\plugins\\sqldrivers\\qsqlpsql.dll: Unknown error 0x000000c1."
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    Available Drivers:  ("QSQLITE", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    Failed to connect to database: "Driver not loaded Driver not loaded"
    

    I checked the username password and the connection using pg admin 4 software with the hostname given above and it responds and works as expected.

    The .dll file is in the path C:\Qt\5.15.2\mingw81_32\plugins\sqldrivers\ as shown in the debug info above and I ran Dependencies on the dll file and I think everything is ok.
    4d0d47b5-3955-4be6-88cc-caf14706b23b-image.png

    I uninstalled PostgreSQL 16 and installed PostgreSQL 9.6 32-bit version and added the bin folder to the System Path, although the actual database is on a linux 64-bit server on the network running PostgreSQL 13.
    What could be the problem that I am not seeing and how do I load the QPSQL library?

    Thank you so much in advance.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      See e.g. https://forum.qt.io/topic/136580/ - are you sure that you built for 32bit?

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

      K 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        See e.g. https://forum.qt.io/topic/136580/ - are you sure that you built for 32bit?

        K Offline
        K Offline
        KK2022
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you for responding.
        Yes I am. I have only one kit configured for this projecct at the moment which is using MinGW 8.1 with QtCreator 14.0.1 (if it matters).

        0275c63c-eaf2-4ff3-8efd-ab236ff07428-image.png
        f8f06dbc-8ddb-45ad-b650-e51cde60e840-image.png

        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