Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[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.
-
ok, thanks but i download Qt with the installer, how can i get sources
-
Hi, you can download the sources "here: ":http://qt-project.org/downloads
-
ok thanks! i'm downloading the sources, how can install them or i have to copy the src directory in my Qt installed directory ?
-
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
-
-
ok thank Clochydd Clochydd i'll try, but i've a Windows 8 64 bit and PostgreSQL9.3 64 bits. I do hope it will work.
thank !
-
Then you can only use this tutorial as a very rough guide as you do not work with the 32-Bit mingw, too.
-
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
-
Hi k_arnaud,
sorry, I made a mistake: It should read "Modify environment" as the variables have to be added. You should set these entries in the CMD-window and have a look at the correct paths - relating to your system.
-
ok, but when you said run the .exe, do you mean Qt creator ?
-
I'm sorry but I do not understand. What do you mean with run the .exe?
-
about the #11 i've installed Qt with msvc2010 not mingw32
-
If you have installed with msvc2010 you cannot work with the 32-Bit postgres. I never worked with msvc2010.
-
ok i'll try with mingw32. thanks
-
Hi Clochydd, i've downloaded Qt with mingw32...
About the #11 here is the error message i get: "cannot find file psql.pro"
-
Hi k_arnaud, the message says that the project file for building the plugin cannot be found.
Did you go to the plugins directory:
8. cd QT_SRC_PATH\src\plugins\sqldrivers\psql
If so, does the psql.pro exist here?
-
after entering mingw32-make debug , in the unreadable message i get, i can see makefile:48: recipe for target 'debug' failed and i get the same with release
-
You should check your pathnames again - it seems that dependencies cannot be found. If you cannot find a fault: What is the unreadable message?
-
may be the problem is from here QTSDK_SQLDRIVERS_PATH=C:\Qt\Qt5.2.0\5.2.1\mingw48_32\plugins\sqldrivers i don't know wehter i should replace "QTSDK_SQLDRIVERS_PATH" with anything
-
Hi k_arnaud, with "set QTSDK_SQLDRIVERS_PATH=C:\Qt\Qt5.2.0\5.2.1\mingw48_32\plugins\sqldrivers" you create the environment-variable QTSDK_SQLDRIVERS_PATH, which you need later (#12.). Where appropriate you must modify the path itself - according to your system.
These variables are for your comfort - you may use the complete pathname instead.
-
that is what i did, i entered QTSDK_SQLDRIVERS_PATH=C:\Qt\Qt5.2.0\5.2.1\mingw48_32\plugins\sqldrivers in the CMD-windows without any change
-
maybe a silly question: did you enter "set QTSDK..." and is that visible in your environment if you type SET in the cmd?
-
No, i ca'nt see that
-
But - do you use SET to bring it to the environment?
-
i tried again, and i can see the three variables; QTSDK_SQLDRIVERS_PATH, QT_SRC_PATH and
POSTGRES32
-
are you able to build the plugin now? You should not see the "recipe" message again.
-
sorry i can't. "qmake is not a command line", that is the error message when i try to buld with CMD-window. But when i try with the the "qt-cmd" i get the same error message "recipe..."
-
must be a wrong path, too:
your_qt_path is something like C:\Qt\Qt5.2.1\5.2.1 and
qmake.exe is located in your_qt_path\mingw48_32\bin
so you must start qmake by:
your_qt_path\mingw48_32\bin\qmake “INCLUDEPATH+=%POSTGRES32%\include” “LIBS+=%POSTGRES32%\lib\libpq.lib” psql.prowhen this task is done, you will continue with:
mingw32-make debug
mingw32-make release
-
here is the error message when i did what you said : cannot find file psql.pro.
that file is not in the qmake.exe directory so when i enter cd C:\Qt\Qt5.2.1\5.2.1\mingw48_32\bin\qmake “INCLUDEPATH+=%POSTGRES32%\include” “LIBS+=%POSTGRES32%\lib\libpq.lib” psql.pro, i get an error message
-
the psql.pro is in the sources, in the plugin\sqldrivers directory (see above cd QT_SRC_PATH\src\plugins\sqldrivers\psql)
you should start your qmake from THIS directory, not from the ...bin dir!
-
When i try to start qmake there, i get an error message "qmake is not a command line..."
-
Do you call qmake with the complete path:
C:\Qt\Qt5.2.1\5.2.1\mingw48_32\bin\qmake
remember to use the path for your machine - maybe you have to modify slightly
-
always the same error "recipe for target 'debug' failed"
-
You must be sure, that all pathnames are correct and the commands are called from the right directories.
-
about "Program~2", for my system it is Program Files (x86). what shall i use ?
-
This follows the 8.3 format, a relict from DOS-times. I think you should use the same name but you can test it in the command window with cd.
-
both work, so i will use Program Files (x86)
-
Hi k_arnaud, you only need the 8.3 format if you have problems with building the plugins - as Windows may refuse to work with spaces in the pathnames.
Did you succeed in building your plugin now?