QPSQL Plugin on Windows
-
hi,
i'm newbie.
my system: win xp sp3, postgresql 9.2, qt 5.0.2
my problem:
i used these "instructions":http://qt-project.org/doc/qt-4.8/sql-driver.html#qpsql to bild my qpsql driver. everything went fine until here:cd %QTDIR%\src\plugins\sqldrivers\psql
qmake "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.proafter this I'm supposed to lunch the nmake command
i received this error: "nmake is not recognized as an internal or external command operable program or batch file"- any idea why i receive this error?
- any idea if the qpsql driver is complete?
- any idea how could i test the qpsql driver?
thanks for your input.
-
Hi and welcome to devnet,
Do you have visual studio properly installed ?
Did you do that from a "developer" command line (either the one started from the visual studio submenu or Qt's) -
hi SGaist, thanks for your reply.
bq. Do you have visual studio properly installed ?
No I don't have Visual Studio installed. During the QT installation I noticed that Microsoft Visual C++ 2005 Redistributable, Microsoft Visual C++ 2008 Redistributable x86, and Microsoft Visual C++ 2010 x86 Redistributable were installed.
Is Visual Studio installed by default during QT installation?
bq. Did you do that from a “developer” command line (either the one started from the visual studio submenu or Qt’s)
All actions were performed from QT command line.
please let me know about the - nmake command
i received this error: “nmake is not recognized as an internal or external command operable program or batch file”- any idea why i receive this error?
- any idea if the qpsql driver is complete?
- any idea how could i test the qpsql driver?
thanks for your input.
-
No, Visual Studio is not part of the Qt installation, it's a Microsoft Product. You can either download it from Microsoft's website or change your Qt installation to use the mingw version which includes the mingw compiler.
-
You receive this error because you don't have Visual Studio installed so none of the tools you'll need are on your system.
-
Yes, the driver is not even compiled
-
You need to first get it compiled. Then you can list all available database drivers with QSqlDatabase::drivers()
-
-
thanks for input. if i could get around installation of VS it would be great.
i made some progress. i found out that instead of running "nmake", this command could be replace by mingw32-make, for the mingw compiler. i run this and i got the following error:
mingw32-make -f Makefile.Release all
mingw32-make1: Entering directory ‘C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/
sqldrivers/psql’
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I“C:\program” – I“files\postgresql\9.2\include” -I“C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include” -I“C:
\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtSql” -I“C:\Qt\Qt5.0.2\5.0.2\mingw47_32\in
clude\QtSql\5.0.2” -I“C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtSql\5.0.2\QtSql”
-I“C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtCore” -I”.moc\release_shared” -I”..
......\mkspecs\win32-g++” -o .obj\release_shared\qsql_psql.o ......\sql\driv
ers\psql\qsql_psql.cpp
......\sql\drivers\psql\qsql_psql.cpp:58:22: fatal error: libpq-fe.h: No such
file or directory
compilation terminated.
Makefile.Release:483: recipe for target ‘.obj/release_shared/qsql_psql.o’ failedmingw32-make1: *** [.obj/release_shared/qsql_psql.o] Error 1
mingw32-make1: Leaving directory ‘C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/s
qldrivers/psql’
makefile:38: recipe for target ‘release-all’ failed
mingw32-make: *** [release-all] Error 2any idea how to get over? the QPSQL driver is not loaded yet.
-
i tried
@@qmake "INCLUDEPATH+=$$quote("path to include") ...
but the syntax might be incomplete. one " is missing, the one opened at "INCLUDEPATH...
bq. Search where is libqp-fe.h located and add that path either in INCLUDEPATH in psql.pro or when running qmake
i couldn't find any libqp-fe.h neither in the postgresql directory, nor in QT.
any suggestion?
-
[quote author="avpro" date="1370168642"]
[quote]Search where is libqp-fe.h located and add that path either in INCLUDEPATH in psql.pro or when running qmake[/quote]i couldn't find any libqp-fe.h neither in the postgresql directory, nor in QT.
any suggestion?
[/quote]From what I have seen previously, the developer libraries does not come default with some PostgreSQL installs. If you want to just create an application that uses PostgreSQL I suggest that you download the developer pre-build dlls from PostgreSQL.
Note the disclaimer on http://www.postgresql.org/download/windows/:
"Advanced users can also download a "zip archive":http://www.enterprisedb.com/products-services-training/pgbindownload of the binaries, without the installer. This is not recommended for normal installations, it is intended for users who wish to include PostgreSQL as part of another application installer."Click on the "zip archive" link above and download the correct archive that you need.
Also, the path should not contain back slashes (''), you should either escape them (replace '' with '\') or replace them with forward slashes ('/').
[quote author="avpro" date="1370168642"]i tried
[quote]qmake "INCLUDEPATH+=$$quote("path to include") ...[/quote]
but the syntax might be incomplete. one " is missing, the one opened at "INCLUDEPATH...
[/quote]Make sure that you have a quote (") after the command to close the quotes started before the INCLUDEPATH. Something in the line of:
@qmake "INCLUDEPATH+=$$quote("path to include")"@
Personally I extarct the binaries into a path without spaces (it helps a lot to simplify things) and then just replace the back- ('') with forward ('/') slashes in your original path, pointing to the extracted lib.
Hope this helps
-
the libs are not standard installed with psql, but they could be installed if the custom installation option is selected, and than select them.
i replaced the "" with "/".
i tried to use the correct command line as described above, and error:"can't find .... \include."
"missing closing parenthesis in function call"
what's wrong? -
what is the exact command that you executed? Something like the following should work:
@qmake "INCLUDEPATH+=C:/psql/include" "LIBS+=C:/psql/lib/ms/libpq.lib" psql.pro
@Or
@
qmake "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro
@I have been using the second one for my PostgreSQL plugin for long now without any problems.
-
thanks for helping me with your precious comments;
please have a look below on my input and my output:C:\Qt\Qt5.0.2\5.0.2>cd src\qtbase\src\plugins\sqldrivers\psql
C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>qmake "INCLUDEPATH+=C
:\program files\postgresql\9.2\include" "LIBS+=C:\program files\postgresql
\9.2\lib\libpq.lib" psql.proC:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory 'C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/
sqldrivers/psql'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\program" -
I"files\postgresql\9.2\include" -I"C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include" -I"C:
\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtSql" -I"C:\Qt\Qt5.0.2\5.0.2\mingw47_32\in
clude\QtSql\5.0.2" -I"C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtSql\5.0.2\QtSql"
-I"C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtCore" -I".moc\release_shared" -I"..
......\mkspecs\win32-g++" -o .obj\release_shared\qsql_psql.o ......\sql\driv
ers\psql\qsql_psql.cpp
......\sql\drivers\psql\qsql_psql.cpp:58:22: fatal error: libpq-fe.h: No such
file or directory
compilation terminated.
Makefile.Release:483: recipe for target '.obj/release_shared/qsql_psql.o' failedmingw32-make[1]: *** [.obj/release_shared/qsql_psql.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/s
qldrivers/psql'
makefile:38: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>
i think this is not much different from my previous post. SGaist suggested:
"Search where is libqp-fe.h located and add that path either in INCLUDEPATH in psql.pro or when running qmake"and i said that "i couldn’t find any libqp-fe.h neither in the postgresql directory, nor in QT. "
i don't have this file.i think worth to mentioned is the path ....C:\psql\lib\ms\libpq.lib" psql.pro. this folder "ms" is missing. the file libpq.lib is located directly in folder "lib". so i skipped this folder in my command.
any idea how to continue, and install this psql driver for QT?
thanks for your input. -
If possible, reinstall postgresql in a path without spaces, that will make you life easier. Otherwise you have to give the old 8.3 name to avoid the space problem.
-
Here is your problem:
[quote author="avpro" date="1370459887"]
C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>qmake "INCLUDEPATH+=C
:\program files\postgresql\9.2\include" "LIBS+=C:\program files\postgresql
\9.2\lib\libpq.lib" psql.pro
...-I"C:\program" -I"files\postgresql\9.2\include"
[/quote]
Because there is spaces in the path to your PostgreSQL install and you did not escape it properly (a user commented on how to handle spaces) the compiler splits your include path at the space and include the above 2 paths, instead of the one that you wanted.So the solution is to either use this comment (read up on the "$$quote()":http://qt-project.org/doc/qt-4.8/qmake-function-reference.html#quote-string command):
[quote author="Hostel" date="1370131524"]You have a spaces in includepath to pg(Program Files for example). From command line try this:
@
qmake "INCLUDEPATH+=$$quote("path to include") ...
@
[/quote]Or the one that I would follow, and the easiest one for future:
[quote author="SGaist" date="1370460739"]If possible, reinstall postgresql in a path without spaces, that will make you life easier. Otherwise you have to give the old 8.3 name to avoid the space problem.[/quote]
-
I come back with more details:
bq.
If possible, reinstall postgresql in a path without spaces, that will make you life easier. Otherwise you have to give the old 8.3 name to avoid the space problem.I reinstalled Posgresql in a folder without spaces.
i run the qmake command once again, and after the mingw32-make.
this is what it resulted:C:\Qt\Qt5.0.2\5.0.2>cd src\qtbase\src\plugins\sqldrivers\psql
C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>qmake "INCLUDEPATH+=c
:\postgresql\9.2\include" "LIBS+=c:\postgresql\9.2\lib\libpq.lib" psql.proC:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory 'C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/
sqldrivers/psql'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\postgresql
\9.2\include" -I"C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include" -I"C:\Qt\Qt5.0.2\5.0.2
mingw47_32\include\QtSql" -I"C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtSql\5.0.2"
-I"C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include\QtSql\5.0.2\QtSql" -I"C:\Qt\Qt5.0.2\5
.0.2\mingw47_32\include\QtCore" -I".moc\release_shared" -I"........\mkspecs\w
in32-g++" -o .obj\release_shared\qsql_psql.o ......\sql\drivers\psql\qsql_psql
.cpp
In file included from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/i686-w64-mingw32/bits/gthr-default.h:41:0,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/i686-w64-mingw32/bits/gthr.h:150,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/ext/atomicity.h:34,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/bits/basic_string.h:41,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/string:54,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/random:41,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/bits/stl_algo.h:67,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/algorithm:63,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qglobal.h:80
,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qatomic.h:42
,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qvariant.h:4
5,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtSql/qsqlresult.h:
45,
from ......\sql\drivers\psql\qsql_psql.h:45,
from ......\sql\drivers\psql\qsql_psql.cpp:42:
C:\postgresql\9.2\include/pthread.h:307:8: error: redefinition of 'struct timesp
ec'
In file included from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/../../../../i686-w64-mingw32/include/time.h:277:0,
from C:\postgresql\9.2\include/pthread.h:218,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/i686-w64-mingw32/bits/gthr-default.h:41,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/i686-w64-mingw32/bits/gthr.h:150,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/ext/atomicity.h:34,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/bits/basic_string.h:41,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/string:54,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/random:41,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/bits/stl_algo.h:67,
from c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/
4.7.2/include/c++/algorithm:63,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qglobal.h:80
,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qatomic.h:42
,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qvariant.h:4
5,
from C:\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtSql/qsqlresult.h:
45,
from ......\sql\drivers\psql\qsql_psql.h:45,
from ......\sql\drivers\psql\qsql_psql.cpp:42:
c:\qt\qt5.0.2\tools\mingw\bin../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686
-w64-mingw32/include/sys/timeb.h:90:8: error: previous definition of 'struct tim
espec'
Makefile.Release:486: recipe for target '.obj/release_shared/qsql_psql.o' failedmingw32-make[1]: *** [.obj/release_shared/qsql_psql.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/s
qldrivers/psql'
makefile:38: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>
the error is: error: previous definition of 'struct timespec'
any idea how this could be resolved?
i found "here":https://bugreports.qt-project.org/browse/QTBUG-9032?actionOrder=desc this report, but i think is for linux.
any experience how to step over this error?thank you all.
-
hi,
i would like to restart the thread. in this moment i'm in the following point:
- i reinstalled PostgreSQL in "C:\psql" to avoid any problems which might come up if Postgresql is installed in "space" separated path, like "C:\Program Files".
- i copied libpq-fe.h, pg_config.h and postgres_ext.h from "c:\psql\include" to "C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql"
- i followed the procedure described "here":http://qt-project.org/doc/qt-4.8/sql-driver.html#qpsql to create the QPSQL plugin
- i replaced "nmake" with "mingw32-make" because i have the MinGw compiler.
Note: the commands are run from Qt's command line prepared by Qt installer.
this is the output:
C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make
mingw32-make
-f Makefile.Release all
mingw32-make[1]:
Entering directory 'C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/
sqldrivers/psql'
g++ -Wl,-s
-shared -Wl,--out-implib,C:\Qt\Qt5.0.2\5.0.2\Src\qtbase\plugins\sqldr
ivers\libqsqlpsql.a
-o ........\plugins\sqldrivers\qsqlpsql.dll .obj/release_
shared/main.o
.obj/release_shared/qsql_psql.o .obj/release_shared/moc_qsql_psql.
o -lpq -LC:\Qt\Qt5.0.2\5.0.2\mingw47_32\lib
-lQt5Sql -lQt5Core
c:/qt/qt5.0.2/tools/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686
-w64-mingw32/bin/ld.exe:
cannot find -lpq
collect2.exe:
error: ld returned 1 exit status
Makefile.Release:80:
recipe for target '........\plugins\sqldrivers\qsqlpsql.
dll' failed
mingw32-make[1]:
[........\plugins\sqldrivers\qsqlpsql.dll] Error 1
mingw32-make[1]:
Leaving directory 'C:/Qt/Qt5.0.2/5.0.2/Src/qtbase/src/plugins/s
qldrivers/psql'
makefile:38:
recipe for target 'release-all' failed
mingw32-make:
[release-all] Error 2any idea what is wrong?
thank you. -
Did you put somewhere the path to libpq ?
-
are you referring to your previous post
bq. Search where is libqp-fe.h located and add that path either in INCLUDEPATH in psql.pro or when running qmakesorry, i'm not sure if i understand correctly: bq. Did you put somewhere the path to libpq ?
could you please try once again?
thanks. -
Sorry,
Did you also do something like:
@LIBS+=-LC:/psql/folder_where_libqp_can_be_found@in your pro file ?