PDA

View Full Version : Building Postgresql driver



gustavospammo
6th May 2014, 10:11
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?

ChrisW67
6th May 2014, 11:05
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.

gustavospammo
6th May 2014, 13:26
:confused:
So, which file should i move? and where?

edit:
You mean i have to add to windows enviroment path?

ChrisW67
6th May 2014, 21:34
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/

gustavospammo
7th May 2014, 08:30
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?

gustavospammo
7th May 2014, 10:39
Now i add c:\postgresql\9.3\bin and c:\postgresql\9.3\lib to windows path as written in
http://stackoverflow.com/questions/11460823/setting-windows-path-for-postgres-tools
but still the same error

ChrisW67
8th May 2014, 00:07
Have you installed 32-bit or 64-bit Postgres libraries? A 32-bit exe will require 32-bit libraries.

Grab Dependency Walker (http://www.dependencywalker.com/). 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.

gustavospammo
8th May 2014, 10:06
Solved
I unistall Postgresql 9.3 64 and install Postgresql 9.3 32bit