Postgresql using QT in Windows: How to compile driver QPSQL - MinGw - Win7
1) check installation directory, in my pc:
PostgreSQL (32 bit) C:\PSQL32\bin
Qt (32 bit) C:\QT\4.8.0\bin
MingW32 C:\QT\qtcreator-2.4.0\mingw\bin
2) add these 3 directory to system PATH
3) Download 'mingw-utils' and install in C:\Qt\4.8.0\bin (need utility REIMP.exe)
4) Convert libpq.lib in useful format for mingw32:
CD C:\PSQL32\lib
REIMP -d libpq.lib
Open libpq.def and delete ALL "_" at the beginning of definitions
dlltool --input-def libpq.def --output-lib libpq.a --dllname libpq.dll
5) Compile:
CD C:\Qt\4.8.0\src\plugins\sqldrivers\psql
qmake -o Makefile "INCLUDEPATH+=C:\PSQL32\include" "LIBS+=C:\PSQL32\lib\libpq.a" psql.pro
mingw32-make debug
mingw32-make release
10) copy dll:
libqsqlpsqld4.a qsqlpsqld4.dll (debug)
libqsqlpsql4.a qsqlpsql4.dll (release)
in the directory:
C:\Qt\4.8.0\plugins\sqldrivers
NEW problem for QT version 5.01
there is a multiple definitions of struct timespec
in file pthread.h of PostgreSQL (C:\PSQL32\include\pthread.h)
replace:
#ifndef HAVE_STRUCT_TIMESPEC
with:
#if ((!defined(_TIMESPEC_DEFINED)) && (!defined(HAVE_STRUCT_TIMESPEC)))
Done :-)
Faust