[Qt-interest] Qt 4.5.1 on Windows and PostgreSQL

Marc Balmer marc at msys.ch
Wed Jun 3 14:43:17 CEST 2009


Am 03.06.2009 um 14:27 schrieb Thiago Macieira:

> Em Quarta-feira 03 Junho 2009, às 14:25:16, Marc Balmer escreveu:
>> Am 03.06.2009 um 12:02 schrieb Marc Balmer:
>>> Hi
>>>
>>> I still havethe problem that using Qt 4.5.1 on Windows there is no
>>> possibility to access a PostgreSQL database (using the Opensource
>>> version of Qt that is compiled using mingw).
>>>
>>> All the instructions on the web are wrong, it is not possible to  
>>> build
>>> the plugin.
>>>
>>> I am a bit desperate now, if someone got this working, I'd be happy
>>> if you can contact me offlist.
>>>
>>> And I sincerely hope the next release will include the plugin...
>>>
>>> - Marc Balmer
>>
>> Sometimes wonders do happen.  I was able to get it working now,
>> case solved ;)
>
> Post your solution to the mailing list. It'll be recorded for  
> posterity and
> will help others who find themselves in a similar situation.

here we go:

the principal problem is that PostgresqL binaries are compiled with
Microsofts compiler whereas the Qt opensource edition is compiled
using mingw.  The library formats are not compatible and the various
solutions posted on the web where you use a tool to convert the library
simply don't work.

The solution is to compile PostgreSQL from source using mingw.  To
do so, install MSYS (no, it has nothing to do with www.msys.ch) and
then extract the postgresql tarball.  Configure it with './configure -- 
without-zlib'
and build it the usual way.  Once PostgreSQL is built and installed,
build the Qt QPSQL plugin in the usual way, indicating the path to
the PostgreSQL includes and library in the qmake step.

To run you application, make sure the file libpq.dll from PostgreSQL
is in the PATH env variable.  Or simply copy libpq.dll to the Qt bin  
dir.

If you run into trouble with this, or can't get it up and running,  
feel free
to buy some consulting hours from me ;P

- Marc Balmer





More information about the Qt-interest-old mailing list