[SOLVED]can't find the "src" directory to build my QPSQL driver
-
Hi,
i've a problem with my Qt application when trying to use a PostgreSQL database. here is the error message i'm getting: QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7.
i've found "here":http://qt-project.org/doc/qt-4.8/sql-driver.html#qpsql a way to build a QPSQL driver but, i don't have any directory named "src" in my Qt installed directory.
can someone help me.
Thanks! -
Hi and welcome to devnet,
It's because you didn't installed the sources. You can grab them from the download page. Just ensure that it matches your current installed Qt.
-
Hi, you can download the sources "here: ":http://qt-project.org/downloads
-
Maybe "this ":http://qt-project.org/forums/viewthread/34609/ will help you.
-
Hi k_arnaud,
I wrote a small tutorial for setting up Qt5.2.1/mingw + PostgreSQL 32-Bit on Win7 - hope it will help:
-
Prepare compiling of the plugin (Lets assume we install Qt + Sources to C:\Qt, PostgresSQL to C:\Programs(86x)):
-
Download Qt 5.2.1 32-bit: http://download.qt-project.org/official_releases/qt/5.2/5.2.1/qt-opensource-windows-x86-mingw48_opengl-5.2.1.exe
-
Run the .exe, install to C:\Qt\Qt5.2.1
-
Download sources: http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.zip
-
Extract zip to C:\Qt\Qt5.2.1
-
Download PostGreSQL 32-bit: http://www.enterprisedb.com/postgresql-932-1-installers-win32?ls=Crossover&type=Crossover
-
Modify PATH:
set QTSDK_SQLDRIVERS_PATH=C:\Qt\Qt5.2.1\5.2.1\mingw48_32\plugins\sqldrivers
set QT_SRC_PATH=C:\Qt\Qt5.2.1\5.2.1\Src\qtbase
set POSTGRES32=C:\Progra~2\PostgreSQL\9.3 (USE Progra~2 FOR Programs(86x)!) -
cd QT_SRC_PATH\src\plugins\sqldrivers\psql
-
add permanently to PATH (Control Panel): C:\Qt\Qt5.2.1\Tools\mingw48_32\bin
-
modify C:\Progra~2\PostgreSQL\9.3\include\pthread.h (multiple definitions of struct timespec):
replace: #ifndef HAVE_STRUCT_TIMESPEC
with: #if ((!defined(_TIMESPEC_DEFINED)) && (!defined(HAVE_STRUCT_TIMESPEC))) -
start building the plugins:
C:\Qt\Qt5.2.1\5.2.1\mingw48_32\bin\qmake “INCLUDEPATH+=%POSTGRES32%\include” “LIBS+=%POSTGRES32%\lib\libpq.lib” psql.pro
mingw32-make debug
mingw32-make release -
copy the newly created plugins to C:\Qt\Qt5.2.1\5.2.1\mingw48_32\plugins\sqldrivers:
copy release\libqsqlpsql.a QTSDK_SQLDRIVERS_PATH
copy release\qsqlpsql.dll QTSDK_SQLDRIVERS_PATH
copy debug\libqsqlpsqld.a QTSDK_SQLDRIVERS_PATH
copy debug\qsqlpsqld.dll QTSDK_SQLDRIVERS_PATH
-
-
Hi Clochydd Clochydd
i downloaded PostgreSQL 32 bit and i tried to follow what you've written. but i can't undersdands the #7, when you say . " Modify PATH:
set QTSDK_SQLDRIVERS_PATH=C:\Qt\Qt5.2.0\5.2.1\mingw48_32\plugins\sqldrivers
set QT_SRC_PATH=C:\Qt\Qt5.2.1\5.2.1\Src\qtbase
set POSTGRES32=C:\Progra~2\PostgreSQL\9.3 (USE Progra~2 FOR Programs(86x)!)" and more of the followingwhen you asked me to run the .exe installed in Qt installed dir, did you mean Qt creator ? if not which .exe i should run ? thanks