0

I am developing an application using QtRuby and PostgreSQL. I successfully developed and running successfully in Linux. Now i want to run the same application in windows. But I am failing to connect to database(postgresql). I am getting the following errors:

 QSqlDatabase: QPSQL driver not loaded
 QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

4 Answers 4

2

As the error message says, the QPSQL driver is not available for Qt to talk to Postgres with. Probably the plugin has not been compiled yet.

As this how-to indicates, you need to install the PostgreSQL developer libraries, and then manually build the Qt driver plugin. See the how-to for the exact commands.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply. I compiled driver and it generated qsqlpsql4.dll, but still i am getting the same error. What should i do now.
0
  1. Compile the QPSQL plugin as instructed here: http://ldc.usb.ve/docs/qt/sql-driver.html#qpsql-for-postgresql-version-7-3-and-above
  2. Add the PostgreSQL bin path to your PATH environment variable

Comments

0

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

1 Comment

Hello, I know it's been a while since this was post. But i am trying to make this work with no success. In my case it doesn't load the driver, but lists it as available. Also, I do not have the code for compiling the plugins. I installed the QT Opensource, tried to alter it and download the codes, but the plugins codes are not provided through the installer. What should I do?
0

Great! It's done! However there are some tips to pay attention: 1. Mingw-utils, 0.4-1 will not work on Windows 7, we must use 0.3. 2. There is a psql.json file in the directory of PSQL driver, please don't delete it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.