PDA

View Full Version : Cannot build PostgreSQL driver



DanMcCoder
28th June 2010, 06:36
Hi Everybody,

I am trying to build the QPSQL driver plugin on Windows using MinGW.
I have followed the instruction at this link:
http://www.qtcentre.org/wiki/index.php?title=Building_the_QPSQL_plugin_on_Windo ws_using_MinGW
but unfortunately with no success.

I have generated libpq.a file using reimp and dlltool
and I have run the following qmake command:

qmake -o Makefile "INCLUDEPATH+=C:\Programmi\PostgreSQL\8.4\include" "LIBS+=C:\Programmi\PostgreSQL\8.4\lib\libpq.a" psql.pro
When I run mingw32-make I get the following output:


C:\Qt\2010.04\qt\src\plugins\sqldrivers\psql>mingw32-make
mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory `C:/Qt/2010.04/qt/src/plugins/sqldrivers/psq
l'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -
DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"..\..\..\..\i
nclude\QtSql" -I"..\..\..\..\include" -I"c:\Programmi\PostgreSQL\8.4\include" -I
"..\..\..\..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\w
in32-g++" -o tmp\obj\debug_shared\main.o main.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -
DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"..\..\..\..\i
nclude\QtSql" -I"..\..\..\..\include" -I"c:\Programmi\PostgreSQL\8.4\include" -I
"..\..\..\..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\w
in32-g++" -o tmp\obj\debug_shared\qsql_psql.o ..\..\..\sql\drivers\psql\qsql_psq
l.cpp
C:\Qt\2010.04\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_AS
CII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT
_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtSql" -I"
..\..\..\..\include" -I"c:\Programmi\PostgreSQL\8.4\include" -I"..\..\..\..\incl
ude\ActiveQt" -I"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\win32-g++" -D__GNU
C__ -DWIN32 ..\..\..\sql\drivers\psql\qsql_psql.h -o tmp\moc\debug_shared\moc_qs
ql_psql.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -
DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"..\..\..\..\i
nclude\QtSql" -I"..\..\..\..\include" -I"c:\Programmi\PostgreSQL\8.4\include" -I
"..\..\..\..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\w
in32-g++" -o tmp\obj\debug_shared\moc_qsql_psql.o tmp\moc\debug_shared\moc_qsql_
psql.cpp
windres -i qsqlpsqld_resource.rc -o tmp\obj\debug_shared\qsqlpsqld_resource_res.
o --include-dir=.
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -shared -Wl,--out-implib,c:\Qt\2010.04\qt\plugins\sqldrivers\li
bqsqlpsqld4.a -o ..\..\..\..\plugins\sqldrivers\qsqlpsqld4.dll tmp/obj/debug_sha
red/main.o tmp/obj/debug_shared/qsql_psql.o tmp/obj/debug_shared/moc_qsql_psql.o
-L"c:\Qt\2010.04\qt\lib" -L"c:\Programmi\SQLXML 4.0\bin\" -L"c:\Qt\2010.04\qt\
lib" tmp\obj\debug_shared\qsqlpsqld_resource_res.o C:\Programmi\PostgreSQL\8.4\l
ib\libpq.a -lQtSqld4 -lQtCored4
Creating library file: c:\Qt\2010.04\qt\plugins\sqldrivers\libqsqlpsqld4. a
tmp/obj/debug_shared/main.o: In function `QPSQLDriverPlugin':
C:\Qt\2010.04\qt\src\plugins\sqldrivers\psql/main.cpp:58: undefined reference to
`_imp___ZN16QSqlDriverPluginC2EP7QObject'
C:\Qt\2010.04\qt\src\plugins\sqldrivers\psql/main.cpp:58: undefined reference to
`_imp___ZN16QSqlDriverPluginC2EP7QObject'
tmp/obj/debug_shared/main.o:C:\Qt\2010.04\qt\src\plugins\sqldrivers\psq l/main.cp
p:64: undefined reference to `_imp___ZNK7QStringeqERK13QLatin1String'
tmp/obj/debug_shared/main.o:C:\Qt\2010.04\qt\src\plugins\sqldrivers\psq l/main.cp
p:64: undefined reference to `_imp___ZNK7QStringeqERK13QLatin1String'
tmp/obj/debug_shared/main.o: In function `QString':
C:\Qt\2010.04\qt\src\plugins\sqldrivers\psql/../../../../include/QtCore/../../sr
c/corelib/tools/qstring.h:683: undefined reference to `_imp___ZN7QString17fromLa
tin1_helperEPKci'
C:\Qt\2010.04\qt\src\plugins\sqldrivers\psql/../../../../include/QtCore/../../sr
c/corelib/tools/qstring.h:715: undefined reference to `_imp___Z9qt_assertPKcS0_i
'
tmp/obj/debug_shared/main.o: In function `~QString':
C:\Qt\2010.04\qt\src\plugins\sqldrivers\psql/../../../../include/QtCore/../../sr
c/corelib/tools/qstring.h:869: undefined reference to `_imp___ZN7QString4freeEPN
S_4DataE'
tmp/obj/debug_shared/main.o: In function `QList':
C:\Qt\2010.04\qt\src\plugins\sqldrivers\psql/../../../../include/QtCore/../../sr
c/corelib/tools/qlist.h:113: undefined reference to `_imp___ZN9QListData11shared
_nullE'

.......


tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x20): undefined reference to `QObject::eventFilter(QOb
ject*, QEvent*)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x24): undefined reference to `QObject::timerEvent(QTim
erEvent*)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x28): undefined reference to `QObject::childEvent(QChi
ldEvent*)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x2c): undefined reference to `QObject::customEvent(QEv
ent*)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x30): undefined reference to `QObject::connectNotify(c
har const*)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x34): undefined reference to `QObject::disconnectNotif
y(char const*)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x5c): undefined reference to `QSqlDriver::sqlStatement
(QSqlDriver::StatementType, QString const&, QSqlRecord const&, bool) const'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x74): undefined reference to `QSqlDriver::setOpen(bool
)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x78): undefined reference to `QSqlDriver::setOpenError
(bool)'
tmp/obj/debug_shared/moc_qsql_psql.o:moc_qsql_psql.cpp:(.rdata$_ZTV11QP SQLDriver
[vtable for QPSQLDriver]+0x7c): undefined reference to `QSqlDriver::setLastError
(QSqlError const&)'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlpsqld4.dll] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/2010.04/qt/src/plugins/sqldrivers/psql
'

The libqsqlpsqld4.a is generated but there is no dll.
I went through these steps several times but I cannot figure out how to solve this problem. I have also followed the instructions at this link where they seem to have the same problem:
http://www.qtcentre.org/threads/18993-Regading-Driver-to-connect-Postgresql-Database/page2 but it didn't work.
This is my configuration: WINXP SP2 / QT 4.6.3 (qt-sdk-win-opensource-2010.04) / PostgreSQL 8.4

Does anybody know how to solve this issue? Is there any other way to get this driver?
Thank you very much for your help

Regards
Daniel

saa7_go
28th June 2010, 08:42
This is how i build postgresql plugin:



qmake "INCLUDEPATH+=C:\Programs\PostgreSQL\8.4\include" "LIBS+=C:\Programs\PostgreSQL\8.4\lib\libpq.lib" psql.pro
qmake
mingw32-make debug
mingw32-make release


I don't use reimp and dlltool, but it works.

DanMcCoder
28th June 2010, 20:12
Thank you for your answer. I have tried your suggestion but I am getting the same error.
I think something is not right with my qt, I am getting "undefined reference" even for QString.
Could this be a problem of environment variables? I installed the sdk (qt-sdk-win-opensource-2010.04)
but I didn't set any environment variables, instead I am working from the Qt Command Prompt that automatically set the followings variables:
-- QTDIR set to C:\Qt\2010.04\qt
-- PATH set to C:\Qt\2010.04\qt\bin
-- Adding C:\Qt\2010.04\bin to PATH
-- Adding C:\WINDOWS\System32 to PATH
-- QMAKESPEC set to win32-g++
Is this correct?

Thanks again

Regards
Daniel

DanMcCoder
30th June 2010, 15:23
After several attempts I was able to solve the problem.
The problem was that my environment variables INCLUDE and LIB were not set.
In order to build the entire Qt library or just a part of it (like my case building QPSQL plugin)
besides extending the "path" variable it is also necessary to set the "include" and "lib" variables with the right paths.
If those two variables are not present, they need to be created.
Here is how I have set my variables:

Created the following new variables:
QTDIR=C:\Qt\4.6.3
MINGW=C:\mingw

Extended "path" variable adding the following paths:
%QTDIR%\bin
%MINGW%\bin

Created "lib" variable with the following paths
%QTDIR%\lib
%MINGW%\lib

Created "include" variable with the following paths
%QTDIR%\include
%MINGW%\include

Please notice I am compiling with MinGW on WINXP, I don't know about other platforms but I imagine it will be somewhat similar.

I hope this will help anybody else having a similar problem.

fhobbies
2nd August 2010, 18:57
same thing for me,
with reimp dlltool make, the build seem works but when i print QSqlDatabase::Drivers in another project, there don't have psql driver

QtCreator 2010.04, QT 4.6.3, GCC 4.4, OS 7

elektrrrus
1st September 2010, 08:58
I find out that compiling plugin with libraries from postgressql 8.4 fail, but with version 8.3 works as described on wiki.