Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved QPSL driver is not loaded Win10 MSVC 2015 x64

    Installation and Deployment
    2
    11
    3598
    Loading More Posts
    • 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.
    • koronabora
      koronabora last edited by

      Hello! I need some help with the most popular question at this section: QPSQL driver is not loaded error.

      OS: Windows 10 x64
      MSVC 2015 x64
      PostgreSQL: 9.5.2 x64
      Qt sql driver: from official installer msvc2015_x64
      

      Dependencies of all libraries checked:
      qt plugin:
      https://yadi.sk/i/J8ybogz1qsamK
      warngings:
      https://yadi.sk/i/W8giYWPiqsapa
      psql:
      https://yadi.sk/i/PON_W6YrqsawK
      warngings:
      https://yadi.sk/i/vx_fjPM-qsazs

      Some code:

      bool SQLContorller::_init()
      {
      	_sqlBase = new QSqlDatabase();
      	_sqlBase->addDatabase(_SQL_DRIVER); //"QPSQL"
      	_sqlBase->setHostName(_host);
      	_sqlBase->setPort(_port);
      	_sqlBase->setDatabaseName(_baseName);
      	_sqlBase->setUserName(_name);
      	_sqlBase->setPassword(_pass);
      	return _sqlBase->open();
      }
      
      

      Debug information from QT:

      QFactoryLoader::QFactoryLoader() looking at "C:/Users/KOT/Documents/Visual Studio 2015/Projects/MoneyManagement/x64/Debug/sqldrivers/qsqlpsqld.dll"
      Found metadata in lib C:/Users/KOT/Documents/Visual Studio 2015/Projects/MoneyManagement/x64/Debug/sqldrivers/qsqlpsqld.dll, metadata=
      {
          "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
          "MetaData": {
              "Keys": [
                  "QPSQL7",
                  "QPSQL"
              ]
          },
          "className": "QPSQLDriverPlugin",
          "debug": true,
          "version": 329216
      }
      
      
      Got keys from plugin meta data ("QPSQL7", "QPSQL")
      "15:00:33 : Starting user manager"
      loaded library "C:/Users/KOT/Documents/Visual Studio 2015/Projects/MoneyManagement/x64/Debug/sqldrivers/qsqlpsqld.dll"
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\NapiNSP.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\pnrpnsp.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\nlaapi.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Users\KOT\Documents\Visual Studio 2015\Projects\MoneyManagement\x64\Debug\sqldrivers\qsqlpsqld.dll'. Cannot find or open the PDB file.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Users\KOT\Documents\Visual Studio 2015\Projects\MoneyManagement\x64\Debug\libpq.dll'. Cannot find or open the PDB file.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\Wldap32.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Users\KOT\Documents\Visual Studio 2015\Projects\MoneyManagement\x64\Debug\ssleay32.dll'. Cannot find or open the PDB file.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Users\KOT\Documents\Visual Studio 2015\Projects\MoneyManagement\x64\Debug\libintl-8.dll'. Module was built without symbols.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Users\KOT\Documents\Visual Studio 2015\Projects\MoneyManagement\x64\Debug\libeay32.dll'. Cannot find or open the PDB file.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\secur32.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\msvcr120.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Users\KOT\Documents\Visual Studio 2015\Projects\MoneyManagement\x64\Debug\libiconv-2.dll'. Module was built without symbols.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\sspicli.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\mswsock.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\winrnr.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\wshbth.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\clbcatq.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\DataExchange.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\d3d11.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\dcomp.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\dxgi.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\twinapi.appcore.dll'. Symbols loaded.
      'MoneyManagement.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. Symbols loaded.
      QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/KOT/Documents/Visual Studio 2015/Projects/MoneyManagement/x64/Debug/accessible" ...
      QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/KOT/Documents/Visual Studio 2015/Projects/MoneyManagement/x64/Debug/accessiblebridge" ...
      "15:00:34 : C:/Users/KOT/Documents/Visual Studio 2015/Projects/MoneyManagement/x64/Debug"
      "15:00:34 : Error while connecting to database!"
      "15:00:34 : Driver not loaded Driver not loaded"
      

      Thank you for help!

      1 Reply Last reply Reply Quote 0
      • koronabora
        koronabora last edited by

        I builded psql plugin using msvc compiler with postgres 9.5.2. Nothing changed.

        Please, could anybody say how to debug this situation: why plugin is not loading? There are no logs about this.

        Thank you!

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi and welcome to devnet,

          Do you also have the folder where the PostgreSQL dlls are in your PATH environment variable ? If not, then simply got to the run part of the Project panel and add it there.

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

          koronabora 1 Reply Last reply Reply Quote 0
          • koronabora
            koronabora @SGaist last edited by koronabora

            @SGaist
            Yes, global %PATH% includes paths to PostgreSQL's dlls:
            https://yadi.sk/i/DP7N4Xx8qvCSB

            And these dll is in a root near a project binaries:

            ssleay32.dll, iconv.dll, libeay32.dll, libiconv-2.dll, libintl-8.dll, libpq.dll, libxml2.dll, libxslt.dll, zlib1.dll

            P.S.

            I'm modified psql driver code by appending some output to console, but nothing appears at console after driver loading:

            QSqlDriver* QPSQLDriverPlugin::create(const QString &name)
            {
                if (name == QLatin1String("QPSQL") || name == QLatin1String("QPSQL7")) {
                    QPSQLDriver* driver = new QPSQLDriver();
                    std::cout << "Driver loaded by main";
                    return driver;
                }
                std::cout << "Driver not loaded by main";
                return 0;
            }
            
            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              After re-reading your plugin loading output, there something strange, did you copy the plugin in your application after building it ?

              It should rather go in Qt's plugins SQL sub folder

              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 Reply Quote 0
              • koronabora
                koronabora last edited by

                I'm sorry.

                Using command line to start application:

                @echo off
                MoneyManagement.exe > out.txt
                

                I see this in file "out.txt":

                Driver loaded by main
                

                In lastSqlError variable the same:

                Driver not loaded Driver not loaded
                

                And there are no error messages in MSVC output.

                What I have to do?

                P.S.

                After appending debug output to all methods inside "qsql_psql_p.h" I saw this:

                Plugin consructor called.
                private sql driver constructor called
                QPSQLDriver constructor 1
                Driver loaded by mainQPSQLDriver close
                QPSQLDriver isOpen
                QPSQLDriver destructor
                
                
                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  After re-reading your code sample I just realized: you're using QSqlDatabase wrongly. You are currently trying to open an invalid database object.

                  addDatabase is a static function. See the detailed description of QSqlDatabase to see how it's done

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

                  koronabora 1 Reply Last reply Reply Quote 1
                  • koronabora
                    koronabora @SGaist last edited by

                    @SGaist

                    Thank you again!

                    _sqlBase = new QSqlDatabase();
                    	*_sqlBase = QSqlDatabase::addDatabase(_SQL_DRIVER); //"QPSQL"
                    

                    Now all is ok.

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      That's wrong, don't allocate _sqlBase on the heap.

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

                      koronabora 1 Reply Last reply Reply Quote 0
                      • koronabora
                        koronabora @SGaist last edited by

                        @SGaist

                        Could you explain to me, why?
                        Thank you.

                        1 Reply Last reply Reply Quote 0
                        • SGaist
                          SGaist Lifetime Qt Champion last edited by

                          One of the reason is explained in QSqlDatbase::removeDatabase.

                          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 Reply Quote 1
                          • First post
                            Last post