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. Static build for SQL plugin
Forum Updated to NodeBB v4.3 + New Features

Static build for SQL plugin

Scheduled Pinned Locked Moved General and Desktop
69 Posts 3 Posters 41.6k Views 1 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.
  • M Offline
    M Offline
    mbnoimi
    wrote on last edited by
    #29

    BTW, Do I've to use libpq.lib OR pq.lib in:
    [code]PRE_TARGETDEPS += C:/PostgreSQL/9.1/lib/pq.lib[/code]

    OR

    [code]PRE_TARGETDEPS += C:/PostgreSQL/9.1/lib/libpq.lib[/code]

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

      You should not need the PRE_TARGETDEPS in this case (unless you are working on the postgresql library and generating the static library yourself)

      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
      • M Offline
        M Offline
        mbnoimi
        wrote on last edited by
        #31

        [quote]You should not need the PRE_TARGETDEPS in this case[/quote]
        I commented this related line(s) but I still get an error!
        [code]QT += core sql

        QT -= gui

        TARGET = TestSSLConnection
        CONFIG += console
        CONFIG -= app_bundle

        TEMPLATE = app

        SOURCES += main.cpp

        win32 {
        LIBS += -LC:/PostgreSQL/9.1/lib -lpg

        PRE_TARGETDEPS += C:/PostgreSQL/9.1/lib/pq.lib

        QMAKE_LFLAGS += -static -static-libgcc -static-libstdc++ -lpthread
        

        }[/code]

        [code]g++ -static -static-libgcc -static-libstdc++ -lpthread -Wl,-s -Wl,-subsystem,console -mthreads -o release\TestSSLConnection.exe release/main.o -LC:/PostgreSQL/9.1/lib -lpg -LC:/Qt/Qt5.1.1-static-sqlite-pgsql/qtbase/lib -lQt5Sql -lpq -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32
        c:/qt/qt5.1.1/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lpg
        Makefile.Release:77: recipe for target 'release\TestSSLConnection.exe' failed
        mingw32-make[1]: Leaving directory 'F:/Snippets/build-TestSSLConnection-Static_pg2-Release'
        makefile:34: recipe for target 'release' failed
        c:/qt/qt5.1.1/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
        mingw32-make[1]: *** [release\TestSSLConnection.exe] Error 1
        mingw32-make: *** [release] Error 2
        12:27:50: The process "C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\mingw32-make.exe" exited with code 2.
        Error while building/deploying project TestSSLConnection (kit: Static-pg2)
        When executing step 'Make'
        12:27:50: Elapsed time: 00:24.[/code]

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

          Are you sure that your Postgresql install is a mingw build ?

          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
          • M Offline
            M Offline
            mbnoimi
            wrote on last edited by
            #33

            [quote]
            Are you sure that your Postgresql install is a mingw build ?
            [/quote]
            I'm not sure what if Postgresql built by MinGW but I'm using the official installer of Postgresql (postgresql-9.1.3-1-windows.exe)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbnoimi
              wrote on last edited by
              #34

              Guys this thread took a long discussion. Does any one built Qt statically with one of SQL plugins (except sqlite)?

              1 Reply Last reply
              0
              • raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #35

                [quote author="mbnoimi" date="1379676626"]Guys this thread took a long discussion. Does any one built Qt statically with one of SQL plugins (except sqlite)?[/quote]

                When your postgresql plugin isn't built with the same compiler it maybe that i can't load the symbols from the DLL.
                Thus to make sure you can try to build it yourself and retry it then.
                Read "this":https://wiki.postgresql.org/wiki/Building_With_MinGW and "this":http://qt-project.org/forums/viewthread/16639.

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

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

                  Also, don't forget the licensing issues with static linking to Qt "explanation here":http://www.slideshare.net/qtbynokia/qt-licensing-explained

                  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
                  • M Offline
                    M Offline
                    mbnoimi
                    wrote on last edited by
                    #37

                    [quote author="raven-worx" date="1379677488"]Thus to make sure you can try to build it yourself and retry it then.
                    Read "this":https://wiki.postgresql.org/wiki/Building_With_MinGW and "this":http://qt-project.org/forums/viewthread/16639.

                    [/quote]

                    I followed up the pointed wiki page by downloading Postgresql from "this link":http://ftp.postgresql.org/pub/source/v9.1.9/postgresql-9.1.9.tar.bz2 then used the following options:

                    [code]$ ./configure --without-zlib --with-openssl --with-includes=C:/OpenSSL-Win32/include --with-libraries=C:/OpenSSL-Win32/lib
                    /MinGW [/code]

                    but I got error during configure process:
                    [code]checking openssl/ssl.h usability... no
                    checking openssl/ssl.h presence... no
                    checking for openssl/ssl.h... no
                    configure: error: header file <openssl/ssl.h> is required for OpenSSL [/code]

                    Do you've an idea how to fix this issue?

                    P.S. "Some guy faced it before":http://web.archiveorange.com/archive/v/V95x82sNS8lCeW2yiGEY but he couldn't find any response :(

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

                      Are you sure the --with-includes and --with-libraries options are valid ? AFAIK it should be -I and -L when calling configure

                      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
                      • M Offline
                        M Offline
                        mbnoimi
                        wrote on last edited by
                        #39

                        [quote author="SGaist" date="1379794681"]Are you sure the --with-includes and --with-libraries options are valid ? AFAIK it should be -I and -L when calling configure[/quote]

                        AFAIK these two options used in Postgresql configure file while -l -L used for Qt.

                        Any way, I'll try to use -l & -L to se if they will affect or not.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mbnoimi
                          wrote on last edited by
                          #40

                          [quote]Are you sure the —with-includes and —with-libraries options are valid ? AFAIK it should be -I and -L when calling configure
                          [/quote]
                          I tried to use -l & -L as you mentioned above but I got this error message. It seems that --with-libraries & --with-includes are the correct options:

                          [code]mbnoimi@MBNOIMI-VBOX ~/postgresql-9.1.9
                          $ ./configure --without-zlib --with-openssl -lC:/OpenSSL-Win32/include -LC:/OpenSSL-Win32/lib/MinGW
                          configure: error: unrecognized option: -lC:/OpenSSL-Win32/include
                          Try `./configure --help' for more information.

                          mbnoimi@MBNOIMI-VBOX ~/postgresql-9.1.9[/code]

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

                            When configuring you have to let a space between -I/-L and the path

                            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
                            • M Offline
                              M Offline
                              mbnoimi
                              wrote on last edited by
                              #42

                              [quote author="SGaist" date="1379882532"]When configuring you have to let a space between -I/-L and the path [/quote]

                              I got same result!

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

                                Did you clean before trying with the space ?

                                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
                                • M Offline
                                  M Offline
                                  mbnoimi
                                  wrote on last edited by
                                  #44

                                  [quote author="SGaist" date="1379883992"]Did you clean before trying with the space ?[/quote]

                                  I used "make confclean"

                                  UPDATE: I got: error message:
                                  [code]mbnoimi@MBNOIMI-VBOX ~/postgresql-9.1.9
                                  $ make confclean
                                  make: *** No rule to make target `confclean'. Stop.[/code]

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

                                    Ok... I didn't realize you were trying to build postgresql... You should rather ask them how to do that

                                    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
                                    • M Offline
                                      M Offline
                                      mbnoimi
                                      wrote on last edited by
                                      #46

                                      [quote]

                                      Ok… I didn’t realize you were trying to build postgresql… You should rather ask them how to do that
                                      [/quote]

                                      Finally I successfully built libpg (Postgresql client) with OpenSSL but now Qt itself gives me error message after calling ming32-make as following:

                                      [code]g++ -c -include release\qt_pch.h -pipe -fno-keep-inline-dllexport -O2 -std=c++0x
                                      -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_USING_NAMESPACE -DQT_BUI
                                      LD_SQL_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_
                                      MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECA
                                      TED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_NO_CAST_FROM_ASCII -DNDEBUG -DSQLIT
                                      E_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABL
                                      E_FTS3_PARENTHESIS -DSQLITE_ENABLE_RTREE -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_C
                                      ORE_LIB -I. -I"F:\Postgresql-static\postgresql-9.1.9\src\include" -I"....\inclu
                                      de" -I"....\include\QtSql" -I"....\include" -I"....\include\QtSql" -I"....\i
                                      nclude\QtSql\5.1.1" -I"....\include\QtSql\5.1.1\QtSql" -I"tmp" -I"..\3rdparty\s
                                      qlite" -I"....\include\QtCore" -I"....\include\QtCore" -I"....\include\QtCore
                                      \5.1.1" -I"....\include\QtCore\5.1.1\QtCore" -I".moc\release_static" -I"." -I"C
                                      :\Qt\Qt5.1.1-static-sqlite-pgsql\qtbase\mkspecs\win32-g++" -o .obj\release_stati
                                      c\qsql_psql.o drivers\psql\qsql_psql.cpp
                                      drivers\psql\qsql_psql.cpp:59:22: fatal error: libpq-fe.h: No such file or direc
                                      tory
                                      #include <libpq-fe.h>
                                      ^
                                      compilation terminated.
                                      Makefile.Release:3320: recipe for target '.obj/release_static/qsql_psql.o' faile
                                      d
                                      mingw32-make[3]: *** [.obj/release_static/qsql_psql.o] Error 1
                                      mingw32-make[3]: Leaving directory 'C:/Qt/Qt5.1.1-static-sqlite-pgsql/qtbase/src
                                      /sql'
                                      Makefile:34: recipe for target 'release' failed
                                      mingw32-make[2]: *** [release] Error 2
                                      mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.1.1-static-sqlite-pgsql/qtbase/src
                                      /sql'
                                      Makefile:207: recipe for target 'sub-sql-make_first' failed
                                      mingw32-make[1]: *** [sub-sql-make_first] Error 2
                                      mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.1.1-static-sqlite-pgsql/qtbase/src
                                      '
                                      makefile:41: recipe for target 'sub-src-make_first' failed
                                      mingw32-make: *** [sub-src-make_first] Error 2[/code]

                                      It crystal clear that this issue related to unknown path although I passed the paths during configure step as following:

                                      [code]configure -no-warnings-are-errors -qt-pcre -qt-libpng -ltcg -release -developer-build -static -qt-sql-sqlite -qt-sql-psql -qt-zlib -qt-libjpeg -opengl desktop -nomake examples -nomake tests -I C:/Postgresql-static/postgresql-9.1.9/src/include -L C:/Postgresql-static/postgresql-9.1.9/src/interfaces/libpq[/code]

                                      ls of libpq folder is:
                                      [code]Postgresql-static/postgresql-9.1.9/src/interfaces/libpq > ls *.h
                                      fe-auth.h libpq-events.h libpq-fe.h libpq-int.h pqexpbuffer.h pqsignal.h win32.h[/code]

                                      NOTE: libpq-fe.h already exists in C:/Postgresql-static/postgresql-9.1.9/src/interfaces/libpq !!!

                                      1 Reply Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        mbnoimi
                                        wrote on last edited by
                                        #47

                                        I fixed the above issue and built Qt successfully by using the following configurations:

                                        [code]configure -no-warnings-are-errors -qt-pcre -qt-libpng -ltcg -release -developer-build -static -qt-sql-sqlite -qt-sql-psql -qt-zlib -qt-libjpeg -opengl desktop -nomake examples -nomake tests -I C:/postgresql-9.1.9/src/include -L C:/postgresql-9.1.9/src/interfaces/libpq -I C:/postgresql-9.1.9/src/interfaces/libpq[/code]

                                        But as soon as I call any SQL class I get linking error although I successfully built Qt and Postgresql by MinGW!
                                        http://pastebin.com/2e8pqnmM

                                        I used the following project to test SQL connectivity:

                                        test.pro
                                        [code]QT += core gui sql

                                        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                                        TARGET = test
                                        TEMPLATE = app

                                        SOURCES += main.cpp
                                        mainwindow.cpp

                                        HEADERS += mainwindow.h

                                        FORMS += mainwindow.ui

                                        QMAKE_LFLAGS += -static -static-libgcc -static-libstdc++ -lpthread

                                        LIBS += -LC:/postgresql-9.1.9/src/interfaces/libpq -lpq
                                        [/code]

                                        main.cpp
                                        [code]QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
                                        db.setHostName("192.168.0.74");
                                        db.setPort(5432);
                                        db.setDatabaseName("testDB");
                                        db.setUserName("postgres");
                                        db.setPassword("pass");
                                        if (!db.open())
                                        qDebug() << "Unable to connect!";
                                        else
                                        qDebug() << "connected.";[/code]

                                        1 Reply Last reply
                                        0
                                        • M Offline
                                          M Offline
                                          mbnoimi
                                          wrote on last edited by
                                          #48

                                          BTW, libpq.a and libpq.dll are exists in in C:\postgresql-9.1.9\src\interfaces\libpq

                                          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