Results 1 to 8 of 8

Thread: Building Postgresql driver

  1. #1
    Join Date
    May 2014
    Posts
    8
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Building Postgresql driver

    Hi, I'm quite a newbie. I used to program a little bit long time ago with Borland C++ Builder 6
    Qt is amazing but the Database stuffs is not realy user friendly ( compare to the old borland 6)
    Now i'm having some trouble with the postgresql driver.
    I've made a little app to open the db but i've got an error:

    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
    QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.

    I found on the internet that i should build the postgresql driver.
    I open C:\Qt\5.2.1\Src\qtbase\src\plugins\sqldrivers\sqld rivers.pro with qt creators but it says i miss some files.
    Then i copied the missing files (libpq-fe.h, pg_config_ext.h, pg_config.h) in folder C:\Qt\5.2.1\Src\qtbase\src\plugins\sqldrivers\psql \
    Now it says "cannot find -lpq"
    What i'm missing?
    Windows 8.1 64 bit
    Qt Creator 3.0.1
    Based on Qt 5.2.1 (MSVC 2010, 32 bit)
    mingw48_32
    Postgresql 9.3 32bit
    xampp 1.7.7 vc9 32bit

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Building Postgresql driver

    The Qt Postgresql plugin is already present in your Qt install so you should not need to build it. The Qt plugin is dependent on the availability of the Postgresql runtime library in the PATH at run time and will not load if that is not available. This is likely what is missing.

  3. #3
    Join Date
    May 2014
    Posts
    8
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Building Postgresql driver


    So, which file should i move? and where?

    edit:
    You mean i have to add to windows enviroment path?
    Last edited by gustavospammo; 6th May 2014 at 16:08.
    Windows 8.1 64 bit
    Qt Creator 3.0.1
    Based on Qt 5.2.1 (MSVC 2010, 32 bit)
    mingw48_32
    Postgresql 9.3 32bit
    xampp 1.7.7 vc9 32bit

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Building Postgresql driver

    You need to install the Postgresql client libraries so that they can be found on the standard Windows search path for DLLs (i.e. The same place as the exe trying to load the dll or on the system PATH). These are not part of Qt.

    On your dev machine just install the Postgresql server: http://www.postgresql.org/download/windows/

  5. #5
    Join Date
    May 2014
    Posts
    8
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Building Postgresql driver

    That's odd.
    I've already installed postgresql server.
    I thought postgresql server should have done it automaticaly..
    Should I uninstall it and try to install it back?

    ot
    I see a lot of people have problems with db drivers on qt.
    why no one has done a post installation tool to automatize the settings?
    Windows 8.1 64 bit
    Qt Creator 3.0.1
    Based on Qt 5.2.1 (MSVC 2010, 32 bit)
    mingw48_32
    Postgresql 9.3 32bit
    xampp 1.7.7 vc9 32bit

  6. #6
    Join Date
    May 2014
    Posts
    8
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Building Postgresql driver

    Now i add c:\postgresql\9.3\bin and c:\postgresql\9.3\lib to windows path as written in
    http://stackoverflow.com/questions/1...postgres-tools
    but still the same error
    Windows 8.1 64 bit
    Qt Creator 3.0.1
    Based on Qt 5.2.1 (MSVC 2010, 32 bit)
    mingw48_32
    Postgresql 9.3 32bit
    xampp 1.7.7 vc9 32bit

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Building Postgresql driver

    Have you installed 32-bit or 64-bit Postgres libraries? A 32-bit exe will require 32-bit libraries.

    Grab Dependency Walker. Run it from the environment your are trying to execute your program from. Locate and open (File menu) the Qt PostgresQL plugin... probably somewhere like:
    C:\Qt\5.2.1\msvc2010\plugins\sqldrivers\qsqlpsql.d ll or qsqlpsqld.dll

    You will be told what direct dependencies are missing.

  8. The following user says thank you to ChrisW67 for this useful post:

    gustavospammo (8th May 2014)

  9. #8
    Join Date
    May 2014
    Posts
    8
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Building Postgresql driver

    Solved
    I unistall Postgresql 9.3 64 and install Postgresql 9.3 32bit
    Windows 8.1 64 bit
    Qt Creator 3.0.1
    Based on Qt 5.2.1 (MSVC 2010, 32 bit)
    mingw48_32
    Postgresql 9.3 32bit
    xampp 1.7.7 vc9 32bit

Similar Threads

  1. Replies: 2
    Last Post: 11th February 2011, 17:53
  2. POSTGRESQL driver for windows
    By drave in forum Newbie
    Replies: 2
    Last Post: 2nd April 2010, 12:44
  3. PostgreSQL driver and Window 7
    By lasher in forum Installation and Deployment
    Replies: 0
    Last Post: 6th October 2009, 16:51
  4. PostgreSQL driver
    By clusty in forum Qt Programming
    Replies: 1
    Last Post: 21st August 2008, 00:55
  5. QT4 and Postgresql driver
    By alphaqt in forum Installation and Deployment
    Replies: 6
    Last Post: 27th February 2006, 15:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.