PDA

View Full Version : PostgreSQL driver support



treyhaslem
9th November 2009, 19:32
I'm using Qt 4.5 on a Windows XP system. I need to connect to a PostgreSQL database. I've done the configure -plugin-sql-psql command and did a mingw32-make afterwards and got the following errors:

collect2: ld returned 1 exit status
mingw32-make[2]: *** [..\..\..\bin\moc.exe] Error 1
mingw32-make[2]: Leaving directory `C:/Qt/2009.04/qt/src/tools/moc'
mingw32-make[1]: *** [release] Error 2
mingw32-make[1]: Leaving directory `C:/Qt/2009.04/qt/src/tools/moc'
mingw32-make: *** [sub-moc-make_default-ordered] Error 2

I've also followed the instructions found at http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW and got the following errors.

'C:/Qt/2009.04/qt/bin/moc.exe' is not recognized as an internal or external comm
and,
operable program or batch file.
mingw32-make[1]: *** [tmp/moc/debug_shared/moc_qsql_psql.cpp] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/2009.04/qt/src/plugins/sqldrivers/psql
'
mingw32-make: *** [debug-all] Error 2

What is going on here???

schnitzel
9th November 2009, 23:02
try these instructions instead:
http://qt.nokia.com/doc/4.0/sql-driver.html#qpsql

but use mingw32-make instead of nmake... worked for me.

treyhaslem
10th November 2009, 01:04
I did. Still doesn't work

schnitzel
10th November 2009, 17:32
you probably are already doing this, but just in case:

1)you are using the qt command prompt - right?
2)PostgreSQL dev headers/libraries are installed and added to the path?

Here are my settings after starting the qt command prompt:

Setting up a MinGW/Qt only environment...
-- QTDIR set to C:\Qt\2009.03\qt
-- PATH set to C:\Qt\2009.03\qt\bin
-- Adding C:\Qt\2009.03\bin to PATH
-- Adding C:\WINDOWS\System32 to PATH
-- QMAKESPEC set to win32-g++

C:\Qt\2009.03\qt>path
PATH=C:\Qt\2009.03\qt\bin;C:\Qt\2009.03\bin;C:\Qt\ 2009.03\mingw\bin;C:\WINDOWS\S
ystem32


if you still encounter problems, try resetting that psql folder to its initial state, i.e. the folder should only contain:
main.cpp
psql.pro
README

One more thing... make sure you don't have any spaces in the path when building the plugin. It is best to use the 8.3 file/folder names or alternatively, install psql to some easy location, i.e. c:\psql.

feraudyh
11th November 2009, 18:35
Hello,
I'm on Win XP, using MingW and have spent a day and a half trying to get the
Qt Postgres driver to work.
I gave up in disgust. It's some kind of a cruel hoax.
In less than an hour I had Libpq running fine, so why even bother with this complicated
system. Life is too short.

treyhaslem
12th November 2009, 17:52
What did you do to get libpq working???

sadjoker
13th November 2009, 02:13
Not so hard.. just made a pri file in the C:/psql dir with include and lib something like
INCLUDEPATH += $$PWD\include
DEPENDPATH += $$PWD\lib
then i added libpq.lib into Qt lib`s dir because it couldn`t find it and then i opened a MSVC 2008 Express Command prompt and compiled Qt`s postgresql plugin for a seconds.

treyhaslem
17th November 2009, 18:56
I created the .pri file called psql.pri with the following:

INCLUDEPATH += $$PWD\include
DEPENDPATH += $$PWD\lib

I placed the file into the c:\psql directory. I copied the libpq.lib file to the C:\Qt\2009.04\qt\lib directory. Do I do a configure -plugin-sql-psql or run qmake?

sadjoker
18th November 2009, 18:05
I created the .pri file called psql.pri with the following:

INCLUDEPATH += $$PWD\include
DEPENDPATH += $$PWD\lib

I placed the file into the c:\psql directory. I copied the libpq.lib file to the C:\Qt\2009.04\qt\lib directory. Do I do a configure -plugin-sql-psql or run qmake?

After u made the pri file go to C:\Qt\4.5.3\src\plugins\sqldrivers\psql
Open psql.pro and add:

include(C:\psql\psql.pri)

Then open a command prompt, cd to where psql.pro is, qmake, make/nmake. I don`t remember if u needed to make install, but do it anyway. The libraries will go to Qt`s plugins dir.

treyhaslem
24th November 2009, 14:36
I can make the libraries but Qt still will not list PostgreSQL as an available database.

doijunior
11th January 2010, 18:25
I can make the libraries but Qt still will not list PostgreSQL as an available database.
I had this problem before and it was resolved with this three steps
-In the prompt go to: cd %QTDIR%
-Then execute the comand: configure -debug-and-release -platform win32-g++ -qt-sql-psql -qt-gif -I C:\PostgreSQL8.1\include -L C:\PostgreSQL8.1\lib
- Finish with: make (or mingw32-make)

davidpiedra
25th October 2010, 23:34
I'm trying to make psql driver available in Qt 4.7 but still no luck.

I manage to compile the driver and build it, all go well, the driver and the libraries were created, but still isn't in the list of available drivers.

Then I make a configure -debug-and-release -platform win32-g++ -qt-sql-psql -I C:\PostgreSQL\9.0\include -L C:\PostgreSQL\9.0\lib, and then mingw32-make, using a Qt commanda prompt and all goes well 'till the psql driver compilation, it gave and error.

I went to the qt\src\plugins\sqldrivers\psql\ and execute mingw32-make Makefile.Debug all (which is exactly where the other make file gave an error) and the make finish ok, the go to qt\ and execute mingw32-make again and this time gave an error on the sqlite driver compìlation; repeat the above steps go to the src\plugins .. and again build ok.

Execute again mingw32-make in the qt\ directory and gave an error in the bearer\generic plugin, again if I go to the directory and build it, the build goes ok;
this keep happening to all plugins, i get tired in the imageformats\gif. This are the errors:

g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\.
.\include\QtCore" -I"..\..\..\..\include\QtGui" -I"..\..\..\..\include" -I"c:\Po
stgreSQL\9.0\include" -I"..\..\..\gui\image" -I"..\..\..\..\include\ActiveQt" -I
"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\win32-g++" -o tmp\obj\debug_shared
\qgifhandler.o ..\..\..\gui\image\qgifhandler.cpp
g++: CreateProcess: No such file or directory
mingw32-make[4]: *** [tmp/obj/debug_shared/qgifhandler.o] Error 1
mingw32-make[4]: Leaving directory `C:/Qt/2010.05/qt/src/plugins/imageformats/gif'
mingw32-make[3]: *** [debug-all] Error 2
mingw32-make[3]: Leaving directory `C:/Qt/2010.05/qt/src/plugins/imageformats/gif'
mingw32-make[2]: *** [sub-gif-make_default] Error 2
mingw32-make[2]: Leaving directory `C:/Qt/2010.05/qt/src/plugins/imageformats'
mingw32-make[1]: *** [sub-imageformats-make_default] Error 2
mingw32-make[1]: Leaving directory `C:/Qt/2010.05/qt/src/plugins'
mingw32-make: *** [sub-plugins-make_default-ordered] Error 2

And still the qpsql driver isn't available. Does anybody find a solution for this.

Thanks.

wysota
25th October 2010, 23:48
You don't need to build the whole Qt if the only thing you are after is recompilation of one sql plugin. Build the plugin and copy it where it belongs, nothing more.

davidpiedra
26th October 2010, 00:10
Thanks for your reply, it is where it belongs in qt\plugins\sqldrivers\psql; but still don't appear to be available.

Could it be possible that the plugin do not find the libpq?

wysota
26th October 2010, 09:01
Yes, it could be possible that it can't find libpq. Use Dependency Walker to see whether its dependencies are met. Also be sure to build the plugin in the right mode (release vs debug).