Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

POSTGRES QPSQL not loading



  • Windows 8.1
    postgres 10 64/32(9.6,32 9.3 32)
    QT 5.10.1
    MinGW 5.3.0 32

    I am wanting to use Qt for a postgres frontend...I am new to Qt, I have been playing with the sample programs. I loaded the SQL Browser . Every time I try to run it I get the : QSqlDatabase: QPSQL driver not loaded.
    I googled till my eyes bled following many directions, copy the LIBPQ.dll , compile my own driver(unsuccessful due to file not found issues again googled to resolve that to no avail) I am at a loss how to make this work. Most of the googled results never seem to resolve much either...Somebody must have made it work. I have tried the MSVC2015 32 and 64 also.



  • I was able to get it to run with mingw 32 build by adding the path to the postgres/bin install to the build environment. I added it to the windows environment originally but that did not seem to work.
    So thanks all for your responses and the help. New to Qt and wanting to see if it something I want to use to connect to our database. The main reason being is we use linux also so I wanted to try it.

    Thanks again for all of your help!!!



  • I had issues with "Driver not loaded" with MySQL .dlls and maybe same thing can help you.

    • Make sure you got this installed
    • Check in environment variables - is the folder containing your LIBPQ.dll a part of systemwide %PATH% variable?

    P.S. If you magically make it work on some other (virtual?) machine, just run ProcExp, select the launched .exe and look for dlls in lower pane, which displays "resource dependencies". Note the path at which normally running .exe expects .dll (or something else). The key to make it launch on your machine then is to put same stuff at same paths



  • I added the environment variable, I have the redistributes 05, 08, 10, 12, 13, 17 for (86) and 64
    it still does not work. I have no access to any virtual window machines.
    I am going to uninstall the different versions of the components and reinstall them, just to make sure I did not hose something up.
    --After reinstall of components it still does not work.
    I followed some directions I found on youtube also, about some dll's to copy to the bin and sqldriver directories to no avail.
    I failed on the second part of the video to make my own drivers, kept getting errors that some files were missing...blah, another rabbit hole I did not want to venture in.


  • Lifetime Qt Champion

    Did you compile Qt5 by yourself?
    Make sure that qsqlpsql(d).dll can find all it's dependencies e.g. with Dependency Walker. Otherwise the library can not be loaded.



  • This post is deleted!

  • Lifetime Qt Champion

    Did you checked the dependencies with Dependency Walker? It's for sure that a needed library is not in your PATH (or maybe there is, but for the wrong architecture... ).



  • When adding the path of libpq.dll, add it to the beginning of your path (when running from QtC, I modify the PATH environment variable to the 'run' configuration instead of my user PATH). I had a similar problem with using postgres and I think there was an older version of the dll somewhere in my path that was causing problems. I'm not sure what version of Postgresql QT expects (or how dependent on the version it is), but 9.6 works for me. Also, run the dependency walker on the qt postgres plugin dll as @Christian-Ehrlicher suggested.



  • I was able to get it to run with mingw 32 build by adding the path to the postgres/bin install to the build environment. I added it to the windows environment originally but that did not seem to work.
    So thanks all for your responses and the help. New to Qt and wanting to see if it something I want to use to connect to our database. The main reason being is we use linux also so I wanted to try it.

    Thanks again for all of your help!!!


Log in to reply