Reputation: 1323
Couldn't find answer myself.
I try to use a power shell script windows-build-qt-static.ps1
to build QT from sources. It's did not working as is, so I modify it. I have download sources manualy, unzip them, place into properly dirrectory, manually patch mkspecs
with
# [QT-STATIC-PATCH]
QMAKE_LFLAGS += -static -static-libgcc
QMAKE_CFLAGS_RELEASE -= -O2
QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer
DEFINES += QT_STATIC_BUILD
and finally I start the power shell script, which contains only following part (the rest code I had remove):
$MingwDir = "c:\Qt\Qt5.7.0\Tools\mingw530_32\"
$QtDir = "c:\Qt\Static\5.7\"
$QtSrcDir = "c:\Qt\Static\src\"
# Set a clean path including MinGW.
$env:Path = "$MingwDir\bin;$MingwDir\opt\bin;$env:SystemRoot\system32;$env:SystemRoot"
# Force English locale to avoid weird effects of tools localization.
$env:LANG = "en"
# Set environment variable QT_INSTALL_PREFIX. Documentation says it should be
# used by configure as prefix but this does not seem to work. So, we will
# also specify -prefix option in configure.
$env:QT_INSTALL_PREFIX = $QtDir
# Configure, compile and install Qt.
Push-Location $QtSrcDir
cmd /c "configure.bat -static -debug-and-release -platform win32-g++ -prefix $QtDir `
-qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -opengl desktop -qt-sql-sqlite -no-openssl `
-make qtserialport -make libs -nomake tools -nomake examples -nomake tests"
mingw32-make -k -j4
mingw32-make -k install
Pop-Location
# Patch Qt's installed mkspecs for static build of application.
$File = "$QtDir\mkspecs\win32-g++\qmake.conf"
@"
CONFIG += static
"@ | Out-File -Append $File -Encoding Ascii
After that, I have compiled QT sources in static libraries, but only following:
This compiled libraries doesn't contains the needed for me (qtserialport, qtcharts, qtconnectivity and other).
Then, I realized, that the mingw32-make
is misconfigured, but I can found that lines in main Makefile
:
...
module-qtserialport-qmake_all: module-qtbase-qmake_all FORCE
@if not exist qtserialport\ mkdir qtserialport\ & if not exist qtserialport\ exit 1
cd qtserialport\ && $(QMAKE) C:\Qt\Static\src\qtserialport\qtserialport.pro -o Makefile
cd qtserialport\ && $(MAKE) -f Makefile qmake_all
module-qtserialport: module-qtbase FORCE
@if not exist qtserialport\ mkdir qtserialport\ & if not exist qtserialport\ exit 1
cd qtserialport\ && ( if not exist Makefile $(QMAKE) C:\Qt\Static\src\qtserialport\qtserialport.pro -o Makefile ) && $(MAKE) -f Makefile
module-qtserialport-make_first: module-qtbase-make_first FORCE
@if not exist qtserialport\ mkdir qtserialport\ & if not exist qtserialport\ exit 1
cd qtserialport\ && ( if not exist Makefile $(QMAKE) C:\Qt\Static\src\qtserialport\qtserialport.pro -o Makefile ) && $(MAKE) -f Makefile
...
I try found out, why many modules did not compile. I tried compile them manually, but I`m failed.
Please help me compile whole Qt Creator (with all modules) into static libs, or build each module as static lib manually.
Upvotes: 0
Views: 971
Reputation: 2534
The build in later Qt versions has been more simplified, no patching is required anymore instead you can use -static-runtime
.
If you want to build Qt 5.7.0 the steps are as following:
Type configure -static -static-runtime -debug-and-release -prefix /your/directory -no-openssl -nomake tools -nomake examples -nomake tests
(add additional features, if you want)
mingw32-make -k -j4 (or jom/make)
mingw32-make -k install (or jom/make)
The shell script was helpful in earlier versions where you had to patch certain variables.
Upvotes: 2