PostgreSQL plugin building in Windows 7



  • Hello all,

    It seems that the building of the PostgreSQL plugin in Windows is a very hard job. I dedicated more than 6 hours today to find out what and how to do and I still cannot build it.

    I have Qt 5.1.1 32-bit with MinGW installed and PostgreSQL 64-bit running on Windows 7 Ultimate 64-bit system.

    Here is my latest findings on the net:

    1. cd C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql
    2. qmake INCLUDEPATH+="d:/PostgreSQL/9.1/include" LIBS+="d:/PostgreSQL/9.1/lib/libpq.lib"
    3. mingw32-make
    4. mingw32-make install

    I managed to do point 2 inclusive like this:
    C:\Qt\5.1.1\mingw48_32\bin>qmake "INCLUDEPATH+=C:\Program Files\PostgreSQL\9.3\include" "LIBS+=C:\Program Files\PostgreSQL\9.3\lib\libpq.lib" C:\Qt\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql

    I used this because when I am in C:\Qt\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql and type qmake.... I got an error that qmake is a not recognized command...

    And now I can't execute points 3 and 4 because of the same error:

    C:\Qt\5.1.1\mingw48_32\bin>mingw32-make
    'mingw32-make' is not recognized as an internal or external command, operable program or batch file.

    So please, someone, make a step-by-step guide how to create this plugin.

    Thanks in advance for your cooperation.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You need to use the console through the link the installer added so the PATH is setup to use Qt and mingw.



  • Hello SGaist,

    Thanks for your answer.

    Could you please divide this into steps which I should take because it is unclear to me?

    Thanks in advance for your cooperation.


  • Lifetime Qt Champion

    Start menu, Programs, Qt 5.1.1, 5.1.1, MinGW 4.8 (32-bit), Qt 5.1.1 for Desktop

    Then you have the command line and can redo the steps you did



  • Hi SGaist,

    Thanks for this.

    This is what I get after inputting this command:

    C:\Qt\5.1.1\mingw48_32>qmake "INCLUDEPATH+=C:\Program%Files\PostgreSQL\9.3\include" "LIBS+=C:\Program%Files\PostgreSQL\9.3\lib\libpq.lib" C:\Qt\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql
    Project ERROR: Project has no top-level .qmake.conf file.


  • Lifetime Qt Champion

    First things, you should move/reinstall PostgreSQL in a folder without space, it will save you a lot of troubles.

    And you should call qmake directly in the plugin folder



  • Hello Sgaist,

    Today I uninstalled PostgreSQL which was 64-bit and installed the 32-bit version. After that I opened the console from Start menu->All Programs->Qt 5.1.1->5.1.1->MinGW 4.8 (32-bit)->Qt 5.1.1 for Desktop.

    After that I went in C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql
    and executed the command:

    C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql>qmake INCLUDE+="C:\PostgreSQL\9.3\include" LIBS+="C:\PostgreSQL\9.3\lib\libpq.lib"

    After that I executed mingw32-make and it started to print output (which is something new) but ended with error. Below is the whole output with the errors at the end:

    C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make
    mingw32-make -f Makefile.Release all
    mingw32-make[1]: Entering directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src/plugins/
    sqldrivers/psql'
    C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_
    NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQ
    T_CORE_LIB -D__GNUC__ -DWIN32 -I. -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include" -I"
    C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtSql" -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32
    include\QtSql\5.1.1" -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtSql\5.1.1\QtSql
    " -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore" -I"C:\Qt\Qt5.1.1\5.1.1\mingw
    48_32\include\QtCore\5.1.1" -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore\5.1
    .1\QtCore" -I".moc\release_shared" -I"........\mkspecs\win32-g++" main.cpp -o
    .moc\release_shared\main.moc
    g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
    all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
    PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\Qt\Qt5.1.1
    \5.1.1\mingw48_32\include" -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtSql" -I"C
    :\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtSql\5.1.1" -I"C:\Qt\Qt5.1.1\5.1.1\mingw4
    8_32\include\QtSql\5.1.1\QtSql" -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore
    " -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore\5.1.1" -I"C:\Qt\Qt5.1.1\5.1.1
    \mingw48_32\include\QtCore\5.1.1\QtCore" -I".moc\release_shared" -I"........
    mkspecs\win32-g++" -o .obj\release_shared\main.o main.cpp
    g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
    all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
    PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\Qt\Qt5.1.1
    \5.1.1\mingw48_32\include" -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtSql" -I"C
    :\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtSql\5.1.1" -I"C:\Qt\Qt5.1.1\5.1.1\mingw4
    8_32\include\QtSql\5.1.1\QtSql" -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore
    " -I"C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore\5.1.1" -I"C:\Qt\Qt5.1.1\5.1.1
    \mingw48_32\include\QtCore\5.1.1\QtCore" -I".moc\release_shared" -I"........
    mkspecs\win32-g++" -o .obj\release_shared\qsql_psql.o ......\sql\drivers\psql
    qsql_psql.cpp
    ......\sql\drivers\psql\qsql_psql.cpp:59:22: fatal error: libpq-fe.h: No such
    file or directory
    #include <libpq-fe.h>
    ^
    compilation terminated.
    Makefile.Release:493: recipe for target '.obj/release_shared/qsql_psql.o' failed

    mingw32-make[1]: *** [.obj/release_shared/qsql_psql.o] Error 1
    mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src/plugins/s
    qldrivers/psql'
    makefile:38: recipe for target 'release-all' failed
    mingw32-make: *** [release-all] Error 2

    Please advise. Your help is much appreciated.


  • Lifetime Qt Champion

    It can't find the libpq-fe.h header file, are you sure you added the include path where that file can be found ?



  • The file is in C:\PostgreSQL\9.3\include:

    !http://imageshack.com/a/img545/2936/i5kg.jpg(libpq-fe)!


  • Lifetime Qt Champion

    Change the \ to / for the paths you give to qmake. Also on windows Qt uses unix style path, so you are giving it invalid paths.



  • same result :)

    ......\sql\drivers\psql\qsql_psql.cpp:59:22: fatal error: libpq-fe.h: No such
    file or directory
    #include <libpq-fe.h>
    ^
    compilation terminated.
    Makefile.Release:493: recipe for target '.obj/release_shared/qsql_psql.o' failed

    mingw32-make[1]: *** [.obj/release_shared/qsql_psql.o] Error 1
    mingw32-make[1]: Leaving directory 'C:/Qt/5.1.1/Src/qtbase/src/plugins/sqldriver
    s/psql'
    makefile:38: recipe for target 'release-all' failed
    mingw32-make: *** [release-all] Error 2


  • Lifetime Qt Champion

    Check the content of the Makefile to see if there's a line containing the path to PostgreSQL includes



  • The Makefile which is in C:/Qt/5.1.1/Src/qtbase/src/plugins/sqldrivers/psql has the line:

    Command: C:\Qt\5.1.1\mingw48_32\bin\qmake.exe INCLUDE+=“C:/PostgreSQL/9.3/include” LIBS+=“C:/PostgreSQL/9.3/lib/libpq.lib” -o Makefile psql.pro

    The Makefile which is in C:\Qt\5.1.1\mingw48_32\bin has the line:

    Command: C:\Qt\5.1.1\mingw48_32\bin\qmake.exe "INCLUDEPATH+=C:\Program Files\PostgreSQL\9.3\include" "LIBS+=C:\Program Files\PostgreSQL\9.3\lib\libpq.lib" -o Makefile C:\Qt\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql\psql.pro


  • Lifetime Qt Champion

    Why do you have a Makefile in the C:\Qt\5.1.1\mingw48_32\bin folder ?

    You should clean everything and then try to build the plugin again



  • I don't know why there is a Makefile :) By clean everything you mean re-install Qt and PostgreSQL ?


  • Lifetime Qt Champion

    No, PostgreSQL seems to be installed fine, just clean the sources and check whether you have something unusual in the mingw related folders



  • Here is what I did:
    -Re-installed Qt
    -Opened the Console from Qt's folder in start menu
    -Executed:

    C:\Qt\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql>qmake INCLUDEPATH+="C:/PostgreSQL/9.3/include" LIBS+="C:/PostgreSQL/9.3/lib/libpq.lib

    After that:
    C:\Qt\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make

    And the result:

                 from c:\qt\tools\mingw48_32\lib\gcc\i686-w64-mingw32\4.8.0\incl
    

    ude\c++\bits\stl_algo.h:65,
    from c:\qt\tools\mingw48_32\lib\gcc\i686-w64-mingw32\4.8.0\incl
    ude\c++\algorithm:62,
    from C:\Qt\5.1.1\mingw48_32\include/QtCore/qglobal.h:80,
    from C:\Qt\5.1.1\mingw48_32\include/QtCore/qnamespace.h:45,
    from C:\Qt\5.1.1\mingw48_32\include/QtCore/qobjectdefs.h:45,
    from C:\Qt\5.1.1\mingw48_32\include/QtCore/qobject.h:48,
    from C:\Qt\5.1.1\mingw48_32\include/QtCore/qplugin.h:45,
    from C:\Qt\5.1.1\mingw48_32\include\QtSql/qsqldriverplugin.h:45
    ,
    from main.cpp:42:
    c:\qt\tools\mingw48_32\i686-w64-mingw32\include\sys\timeb.h:90:8: error: previou
    s definition of 'struct timespec'
    struct timespec {
    ^
    Makefile.Release:397: recipe for target '.obj/release_shared/main.o' failed
    mingw32-make[1]: *** [.obj/release_shared/main.o] Error 1
    mingw32-make[1]: Leaving directory 'C:/Qt/5.1.1/Src/qtbase/src/plugins/sqldriver
    s/psql'
    makefile:38: recipe for target 'release-all' failed
    mingw32-make: *** [release-all] Error 2

    Is it possible that for Qt ver. 5.1.1 the building of the plugin is done in different way?


  • Lifetime Qt Champion

    Just stumbled upon "this":http://qt-project.org/forums/viewthread/24460
    Worth a try


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.