Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PostgreSQL and Trying to connect using Qt
Forum Updated to NodeBB v4.3 + New Features

PostgreSQL and Trying to connect using Qt

Scheduled Pinned Locked Moved General and Desktop
46 Posts 8 Posters 42.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aftertaf
    wrote on last edited by
    #22

    1: Thanks for taking time out :)
    2: OK, i've just reviewed and adapted to my environment slightly

    I get this error:
    @g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1\QtCore" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore" -I".moc\debug" -I"........\mkspecs\win32-g++" -o .obj\debug\qsql_psql.o ......\sql\drivers\psql\qsql_psql.cpp
    ......\sql\drivers\psql\qsql_psql.cpp:59:22: fatal error: libpq-fe.h: No suchfile or directory
    #include <libpq-fe.h>
    ^
    compilation terminated.
    Makefile.Debug:497: recipe for target '.obj/debug/qsql_psql.o' failed
    mingw32-make[1]: *** [.obj/debug/qsql_psql.o] Error 1
    mingw32-make[1]: Leaving directory 'c:/QT/5.2.1/Src/qtbase/src/plugins/sqldrivers/psql'
    makefile:48: recipe for target 'debug' failed
    mingw32-make: *** [debug] Error 2@

    my path & env.vars set in the dos prompt:(which matches, i have triple checked)
    set QTSDK_SQLDRIVERS_PATH=C:\QT\5.2.1\mingw48_32\plugins\sqldrivers
    set QT_SRC_PATH=c:\QT\5.2.1\Src\qtbase
    set POSTGRES32=c:\psql93_x86

    C:\Qt\5.2.1\mingw48_32\bin;C:\Qt\Tools\mingw48_32\bin;C:\Qt\Tools\QtCreator\bin;C:\psql93_x86\bin;C:\psql93_x86\lib;C:\psql93_x86\include;C:\psql93_x86\include\libpq;C:\Perl\site\bin;C:\Perl\bin;C:\Windows;C:\Windows\system32;C:\Windows\System32\WindowsPowerShell\v1.0\C:\Windows\System32\Wbem;C:\trace;C:\trace\dll;c\trace\prod;C:\windev55;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE;C:\Program Files (x86)\Microsoft Application Virtualization Client;C:\Program Files\doxygen\bin

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aftertaf
      wrote on last edited by
      #23

      Forum post typo:
      i do have libpq-fe.h in c:\psql93_x86\include\ (not c:\pgsql93_x86\include)
      20.5k, dated 3rd Dec 2013

      1 Reply Last reply
      0
      • C Offline
        C Offline
        clochydd
        wrote on last edited by
        #24

        But c:\pgsql93_86\include\ is not in the maker's includepath
        See my suggestion item 11.:
        [11. start building the plugins:
        C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin\qmake “INCLUDEPATH+=%POSTGRES32%\include” “LIBS+=%POSTGRES32%\lib\libpq.lib” psql.pro]
        good luck!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aftertaf
          wrote on last edited by
          #25

          that's what i'm doing, exactly...
          but still not finding it.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #26

            And what if you replace %POSTGRES32% with the actual path BUT using forward slashes

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aftertaf
              wrote on last edited by
              #27

              result (again)
              @C:\QT\5.2.1\Src\qtbase\src\plugins\sqldrivers\psql>C:\Qt\5.2.1\mingw48_32\bin\qmake "INCLUDEPATH+=c:/psql93_x86/include" "LIBS+=c:/psql93_x86/lib/libpq.lib" psql.pro

              C:\QT\5.2.1\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make debug
              mingw32-make -f Makefile.Debug
              mingw32-make[1]: Entering directory 'C:/QT/5.2.1/Src/qtbase/src/plugins/sqldrivers/psql'
              g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1\QtCore" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore" -I".moc\debug" -I"........\mkspecs\win32-g++" -o .obj\debug\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.Debug:497: recipe for target '.obj/debug/qsql_psql.o' failed
              mingw32-make[1]: *** [.obj/debug/qsql_psql.o] Error 1
              mingw32-make[1]: Leaving directory 'C:/QT/5.2.1/Src/qtbase/src/plugins/sqldrivers/psql'
              makefile:48: recipe for target 'debug' failed
              mingw32-make: *** [debug] Error 2
              @

              Relevant env vars:(edited for readability)
              Path=
              C:\Qt\5.2.1\mingw48_32\bin;
              C:\Qt\Tools\mingw48_32\bin;
              C:\Qt\Tools\QtCreator\bin;
              C:\psql93_x86\bin;
              C:\psql93_x86\lib;
              C:\psql93_x86\include;
              C:\psql93_x86\include\libpq;
              C:\Perl\site\bin;
              C:\Perl\bin;
              C:\Windows;
              C:\Windows\system32;
              C:\Program Files\doxygen\bin
              PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.BPL;.lib
              POSTGRES32=c:\psql93_x86
              POSTGRES322=c:/psql93_x86
              QTSDK_DRIVERSPATH=C:\QT\5.2.1\mingw48_32\plugins\sqldrivers
              QTSDK_DRIVERSPATH2=C:/QT/5.2.1/mingw48_32/plugins/sqldrivers
              QT_SRC_PATH=C:\Qt\5.2.1\Src\qtbase
              QT_SRC_PATH2=C:/Qt/5.2.1/Src/qtbase

              1 Reply Last reply
              0
              • A Offline
                A Offline
                aftertaf
                wrote on last edited by
                #28

                tried a different approach, still NOK.

                copied all of the c:\psql93_x86\include folder (+subdirs) into C:\QT\5.2.1\Src\qtbase\src\plugins\sqldrivers\psql (directory the make enters before the fail)

                it gets further before borking.
                @C:\Qt\5.2.1\mingw48_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D__GNUC__-DWIN32 -I. -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1\QtCore" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore" -I".moc\debug" -I"........\mkspecs\win32-g++" ......\sql\drivers\psql\qsql_psql_p.h -o .moc\debug\moc_qsql_psql_p.cpp
                g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1\QtCore" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore" -I".moc\debug" -I"........\mkspecs\win32-g++" -o .obj\debug\moc_qsql_psql_p.o.moc\debug\moc_qsql_psql_p.cpp
                g++ -shared -Wl,--out-implib,C:\QT\5.2.1\Src\qtbase\plugins\sqldrivers\libqsqlpsqld.a -o ........\plugins\sqldrivers\qsqlpsqld.dll .obj/debug/main.o .obj/debug/qsql_psql.o .obj/debug/moc_qsql_psql_p.o -lpq -LC:\Qt\5.2.1\mingw48_32\lib -lQt5Sqld -lQt5Cored

                c:/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lpq
                collect2.exe: error: ld returned 1 exit status
                Makefile.Debug:80: recipe for target '........\plugins\sqldrivers\qsqlpsqld.dll' failed
                mingw32-make[1]: *** [........\plugins\sqldrivers\qsqlpsqld.dll] Error 1
                mingw32-make[1]: Leaving directory 'C:/QT/5.2.1/Src/qtbase/src/plugins/sqldrivers/psql'
                makefile:48: recipe for target 'debug' failed
                mingw32-make: *** [debug] Error 2@
                i'm so close i can smell the SELECT*, but still no cigar

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  aftertaf
                  wrote on last edited by
                  #29

                  You are using mingw32's gcc to compile qt and trying to use postgreql library compiled with MSVC.

                  MSVC uses .LIB for libraries while Mingw32 (gcc + binutils) uses .a or .so files for libraries.

                  You can try either of the following methods: a. compile Qt using MSVC. b. use mingw32 to compile postgresql and use its libraries.
                  From:
                  http://stackoverflow.com/questions/5487236/building-qt-postgresql-driver

                  anyone have an easy to follow 'how to build postgres from sources with mingw '?
                  or easier still, how to "use" the "QT" ODBC driver instead?

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    aftertaf
                    wrote on last edited by
                    #30

                    ...
                    just build libpq.a from sources . . . .
                    http://pgolub.wordpress.com/2008/12/15/building-postgresql-client-library-using-mingw-under-winxp-sp3/

                    don't know what to do with it.
                    sorry for by n00bness, people...

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      clochydd
                      wrote on last edited by
                      #31

                      It is not necessary to compile postgresql, I used the binaries 32-bit and with installing ./lib and ./include had been provided, too.
                      Your make does not recognise the psql includes (the stuff, that follows -I) and that's why you still receive the message 'libpq-fe.h not found'.
                      Do you see the same error if you use backslashed paths with you qmake command? Qt uses forward slashes but I had success with the backslashed command.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #32

                        Just to be sure, wouldn't by any chance libpq-fe.h be in include/libpq ? If so it's that last element that was missing.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          clochydd
                          wrote on last edited by
                          #33

                          Yes, this has been installed in "C:\Program Files (x86)\PostgreSQL\9.3\include" together with the binaries of PostgeSQL 32-bit:
                          "03.12.2013 06:13 21.082 libpq-fe.h"
                          and - the PostgreSQl include has to be added to qmake!

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #34

                            Indeed, but you need to give the full path to libqp-fe.h not just the path that contains the libpq folder.

                            Please avoid having spaces in your path when developing, it something that is not working very well on windows

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              aftertaf
                              wrote on last edited by
                              #35

                              on my system i installed postgreSQL x86 9.3 to c:\psql93_x86\

                              so... the qmake command where i specify the INCLUDE+=, LIBS+= etc . . .
                              i need to tell it precisely and exactly where libqp-fe.h is, including full path ?

                              how do I do that, i.e. what separator do i use to add more than one entry into the "INCLUDE+=" that i've already specified (using clochydd's tuto on page 2. .) ?

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                clochydd
                                wrote on last edited by
                                #36

                                Go to the Qt plugin source directory:
                                cd QT_SRC_PATH\src\plugins\sqldrivers\psql

                                Start building the plugins:
                                (Change this to your mingw32 path: C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin)
                                C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin\qmake “INCLUDEPATH+=c:\psql93_x86\include”
                                “LIBS+=c:\psql93_x86\lib\libpq.lib” psql.pro

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #37

                                  libpq-fe.h being in include/libpq

                                  You should use

                                  @“INCLUDEPATH+=c:/psql93_x86/include/libpq”@

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    aftertaf
                                    wrote on last edited by
                                    #38

                                    same :(

                                    1 Reply Last reply
                                    0
                                    • C Offline
                                      C Offline
                                      clochydd
                                      wrote on last edited by
                                      #39

                                      Don't give up - we will find a solution, hopefully!

                                      • Is the qmake error message concerning the libpq-fe.h exactly as before?
                                      • Could you please post the message again?
                                      • Could you post the directory list of c:\psql93_x86\include?
                                      1 Reply Last reply
                                      0
                                      • A Offline
                                        A Offline
                                        aftertaf
                                        wrote on last edited by
                                        #40

                                        just tried making the odbc driver again...
                                        and get the Driver not Loaded message :)


                                        C:\QT\5.2.1\Src\qtbase\src\plugins\sqldrivers\psql>c:\Qt\5.2.1\mingw48_32\bin\qm
                                        ake.exe "INCLUDEPATH+=c:/psql93_x86/include/libpq" "LIBS+=c:/psql93_x86/lib/libp
                                        q.lib" psql.pro

                                        C:\QT\5.2.1\Src\qtbase\src\plugins\sqldrivers\psql>mingw32-make debug
                                        mingw32-make -f Makefile.Debug
                                        mingw32-make[1]: Entering directory 'C:/QT/5.2.1/Src/qtbase/src/plugins/sqldrive
                                        rs/psql'
                                        g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wa
                                        ll -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEP
                                        TIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"C:\Qt\5.2.1\mingw48_32\inclu
                                        de\QtSql\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql\5.2.1\QtSql" -I"C:\Qt\5.
                                        2.1\mingw48_32\include" -I"C:\Qt\5.2.1\mingw48_32\include\QtSql" -I"C:\Qt\5.2.1
                                        mingw48_32\include\QtCore\5.2.1" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore\5.2.1
                                        QtCore" -I"C:\Qt\5.2.1\mingw48_32\include\QtCore" -I".moc\debug" -I"........
                                        mkspecs\win32-g++" -o .obj\debug\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.Debug:497: recipe for target '.obj/debug/qsql_psql.o' failed
                                        mingw32-make[1]: *** [.obj/debug/qsql_psql.o] Error 1
                                        mingw32-make[1]: Leaving directory 'C:/QT/5.2.1/Src/qtbase/src/plugins/sqldriver
                                        s/psql'
                                        makefile:48: recipe for target 'debug' failed
                                        mingw32-make: *** [debug] Error 2

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          aftertaf
                                          wrote on last edited by
                                          #41

                                          http://pastebin.com/4cpqVMiN
                                          folder contents

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved