Static build for SQL plugin
-
I found this link which it talks about static building but unfortunately it done with Qt4 which isn't work perfectly with Qt5.
The issue still on how to add Postgresql paths to configure.bat to be able to add them during make process mingw32-make
-
Sorry I forgot to add the link:
http://www.qtcentre.org/threads/5781-Want-a-static-database-plugin-tried-a-lot-but-have-still-DLL-dependecies -
SGaist, thanks a lot for your effort in helping me :)
Voila, I successfully built Qt statically with Postgresql plugin option as following (it was stupid Windows issue so after formatting Windows the problem solved):
[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/include -L C:/PostgreSQL/9.1/lib/[/code]But Qt it self coudln't link pg libratry for usual Qt projects. In the following .pro of test project uses QPSQL:
[code]QT += core sql
QT -= gui
TARGET = TestSSLConnection
CONFIG += console
CONFIG -= app_bundleTEMPLATE = 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]It generates the following error on building process:
[code]mingw32-make[1]: Leaving directory 'F:/build-TestSSLConnection-Satic_postgresql-Release'
mingw32-make[1]: *** No rule to make target 'C:/PostgreSQL/9.1/lib/pq.lib', needed by 'release\TestSSLConnection.exe'. Stop.
makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
16:08:31: 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: Satic-postgresql)
When executing step 'Make'
16:08:31: Elapsed time: 00:14.[/code]How can I fix this issue?
-
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]
-
You should not need the PRE_TARGETDEPS in this case (unless you are working on the postgresql library and generating the static library yourself)
-
[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 sqlQT -= gui
TARGET = TestSSLConnection
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
win32 {
LIBS += -LC:/PostgreSQL/9.1/lib -lpgPRE_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] -
Are you sure that your Postgresql install is a mingw build ?
-
[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) -
Guys this thread took a long discussion. Does any one built Qt statically with one of SQL plugins (except sqlite)?
-
[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. -
Also, don't forget the licensing issues with static linking to Qt "explanation here":http://www.slideshare.net/qtbynokia/qt-licensing-explained
-
[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 :(
-
Are you sure the --with-includes and --with-libraries options are valid ? AFAIK it should be -I and -L when calling configure
-
[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.
-
[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]
-
When configuring you have to let a space between -I/-L and the path
-
[quote author="SGaist" date="1379882532"]When configuring you have to let a space between -I/-L and the path [/quote]
I got same result!
-
Did you clean before trying with the space ?
-
[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] -
Ok... I didn't realize you were trying to build postgresql... You should rather ask them how to do that