How to build Qt 5.4 statically on Window 7. Compression exe by upx
-
Hello!
I built Qt 5.4 successfully. I receive exe files at the minimum 14 MBytes. I compress them to ~5.5 MBytes by upx.exe
This is my instruction:
Move to the folder: C:\Qt\Qt5.4.0\5.4\mingw491_32\mkspecs\win32-g++\
Save copy of the file "qmake.conf" with the name for example: "qmake_copy.conf"
Change the the line in "qmake.conf":
bq. QMAKE_LFLAGS =
to:
bq. QMAKE_LFLAGS += -static-libgcc -static -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
Add the line after DEFINES += UNICODE:
bq. DEFINES += QT_STATIC_BUILD
Move to here: C:\Qt\Qt5.4.0\5.4\ and save copy of the "Src" folder. For example, add the "Src" folder to the archive "Src.zip"
Open the terminal: "Start" -> "All Programs" -> "Qt 5.4.0" -> "5.4" -> "MinGW 4.9 (32 bit)" -> "Qt 5.4.0 for Desktop (MinGW 4.9 32 bit)"
bq. cd C:\Qt\Qt5.4.0\5.4\Src\
bq. configure -static -platform win32-g++ -prefix "C:\Qt\Qt5.4.0_Static" -release -opensource -confirm-license -nomake examples -nomake tests -nomake tools -opengl desktop -no-angle -qt-sql-sqlite -make libs -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype
bq. mingw32-make
bq. mingw32-make install
You will have a static Qt here "C:\Qt\Qt5.4.0_Static"
Move to the folder: C:\Qt\Qt5.4.0\5.4\mingw491_32\mkspecs\win32-g++\
Delete the file "qmake.conf" and rename "qmake_copy.conf" to "qmake.conf"
Move to here: C:\Qt\Qt5.4.0\5.4\ Delete "Src" folder. Dearchive "Src.zip"
Run QtCreator
In the menu select "Tools" -> select "Options"
Select "Build & Run" -> select "Qt Vertions"
Click the button "Add..." -> select "C:\Qt\Qt5.4.0_Static\bin\qmake.exe"
Click the button "Apply"
Select "Kits" -> click the button "Add"
Write in the filed "Name": Desktop Qt 5.4.0 Static MinGW 32 bit
If the field "Debugger" is empty, click the button "Manage..."
Click the button "Add" -> write the name (for example gdb) -> select "C:\Qt\Qt5.4.0\Tools\mingw49_32\bit\gdb.exe"
Click the button "Apply"
Select "Kits"
Select in the list "Qt versions": "Desktop Qt 5.4.0 Static MinGW 32 bit"
Click the button "OK"
-
Notes
You need to ignore this output after the finish this command: mingw32-make
bq. python C:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/src/3rdparty/masm/create_regex_tables
RegExpJitTables.h
/c/cygwin64/bin/python: /c/cygwin64/bin/python: cannot execute binary file
Makefile.Release:1093: recipe for target 'RegExpJitTables.h' failed
mingw32-make[4]: *** [RegExpJitTables.h] Error 126
mingw32-make[4]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/src/qml'
Makefile:34: recipe for target 'release' failed
mingw32-make[3]: *** [release] Error 2
mingw32-make[3]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/src/qml'
Makefile:45: recipe for target 'sub-qml-make_first-ordered' failed
mingw32-make[2]: *** [sub-qml-make_first-ordered] Error 2
mingw32-make[2]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/src'
Makefile:41: recipe for target 'sub-src-make_first' failed
mingw32-make[1]: *** [sub-src-make_first] Error 2
mingw32-make[1]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative'
makefile:217: recipe for target 'module-qtdeclarative-make_first' failed
mingw32-make: *** [module-qtdeclarative-make_first] Error 2You need to ignore this output after the finish this command: mingw32-make install
bq. c:/Qt/Qt5.4.0/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../.
./i686-w64-mingw32/bin/ld.exe: C:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/lib/libQt5Qml
.a(YarrInterpreter.o): bad reloc address 0x12 in section `.text$_ZN3WTF15BumpPoi
nterPool6createEj[__ZN3WTF15BumpPointerPool6createEj]'
collect2.exe: error: ld returned 1 exit status
Makefile.Release:86: recipe for target '../../bin/qml.exe' failed
mingw32-make[4]: *** [../../bin/qml.exe] Error 1
mingw32-make[4]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/tools/qm
l'
Makefile:44: recipe for target 'release-install' failed
mingw32-make[3]: *** [release-install] Error 2
mingw32-make[3]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/tools/qm
l'
Makefile:107: recipe for target 'sub-qml-install_subtargets' failed
mingw32-make[2]: *** [sub-qml-install_subtargets] Error 2
mingw32-make[2]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative/tools'
Makefile:78: recipe for target 'sub-tools-install_subtargets' failed
mingw32-make[1]: *** [sub-tools-install_subtargets] Error 2
mingw32-make[1]: Leaving directory 'c:/Qt/Qt5.4.0/5.4/Src/qtdeclarative'
makefile:229: recipe for target 'module-qtdeclarative-install_subtargets' failed
mingw32-make: *** [module-qtdeclarative-install_subtargets] Error 2 -
I improved my instruction. You don't need reinstall Qt. You need save the backup copy of the "qmake.conf" and the "Src" folder
-
What if the src folder is missing like in my case where there are no src folder?
-
Nevermind.. I installed som add ons and it suddently apperead in my Qt folder.
-
[quote author="Cannabis2011" date="1419182935"]What if the src folder is missing like in my case where there are no src folder?[/quote]
See the picture: http://i9.pixs.ru/storage/2/1/1/QtSourcepn_3760970_15267211.png
-
That was exactly what i did :-D
-
Please, help me!
I want to build Qt statically on Linux Mint 13. This is my steps:
After I instaled Linux Mint 13 I ran this command:
bq. sudo apt-get install build-essential ^libxcb.* libx11-xcb-dev libglu1-mesa-dev libxrender-dev libfontconfig1-dev
Then I moved to Src directory and ran:
bq. ./configure -prefix "/home/ivan/Qt5.4.0_Static" -static -platform linux-g++ -release -opensource -confirm-license -fontconfig -no-compile-examples -nomake examples -nomake tests -nomake tools -opengl desktop -qt-sql-sqlite -make libs -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype
I received:
@Configure summary
Build type: linux-g++ (i386, CPU features: none detected)
Build options:
Configuration .......... accessibility accessibility-atspi-bridge audio-backend avx c++11 clock-gettime clock-monotonic concurrent evdev eventfd fontconfig full-config getaddrinfo getifaddrs gif harfbuzz iconv inotify ipv6ifname jpeg large-config largefile linuxfb medium-config minimal-config mremap nis opengl pcre png posix_fallocate precompile_header qpa qpa reduce_exports reduce_relocations release rpath small-config sse2 sse3 sse4_1 sse4_2 ssse3 static system-freetype xcb xcb-glx xcb-plugin xcb-render xcb-xlib xkbcommon-qt xlib xrender zlib
Build parts ............ libs
Mode ................... release
Using C++11 ............ yes
Using gold linker....... no
Using PCH .............. yes
Target compiler supports:
SSE2/SSE3/SSSE3 ...... yes/yes/yes
SSE4.1/SSE4.2 ........ yes/yes
AVX/AVX2 ............. yes/noQt modules and options:
Qt D-Bus ............... runtime
Qt Concurrent .......... yes
Qt GUI ................. yes
Qt Widgets ............. yes
Large File ............. yes
QML debugging .......... yes
Use system proxies ..... noSupport enabled for:
Accessibility .......... yes
ALSA ................... no
CUPS ................... no
Evdev .................. yes
FontConfig ............. yes
FreeType ............... yes (system library)
Glib ................... no
GTK theme .............. no
HarfBuzz ............... yes (bundled copy)
Iconv .................. yes
ICU .................... no
Image formats:
GIF .................. yes (in QtGui, using bundled copy)
JPEG ................. yes (in QtGui, using bundled copy)
PNG .................. yes (in QtGui, using bundled copy)
journald ............... no
mtdev .................. no
Networking:
getaddrinfo .......... yes
getifaddrs ........... yes
IPv6 ifname .......... yes
OpenSSL .............. no
NIS .................... yes
OpenGL / OpenVG:
EGL .................. no
OpenGL ............... desktop
OpenVG ............... no
PCRE ................... yes (bundled copy)
pkg-config ............. yes
PulseAudio ............. no
QPA backends:
DirectFB ............. no
EGLFS ................ no
KMS .................. no
LinuxFB .............. yes
XCB .................. yes (system library)
EGL on X ........... no
GLX ................ yes
MIT-SHM ............ yes
Xcb-Xlib ........... yes
Xcursor ............ yes (loaded at runtime)
Xfixes ............. yes (loaded at runtime)
Xi ................. yes (loaded at runtime)
Xi2 ................ no
Xinerama ........... yes (loaded at runtime)
Xrandr ............. yes (loaded at runtime)
Xrender ............ yes
XKB ................ no
XShape ............. yes
XSync .............. yes
XVideo ............. yes
Session management ..... yes
SQL drivers:
DB2 .................. no
InterBase ............ no
MySQL ................ no
OCI .................. no
ODBC ................. no
PostgreSQL ........... no
SQLite 2 ............. no
SQLite ............... qt-qt
TDS .................. no
udev ................... no
xkbcommon .............. yes (bundled copy, XKB config root: /usr/share/X11/xkb)
zlib ................... yes (bundled copy)WARNING: Using static linking will disable the use of dynamically
loaded plugins. Make sure to import all needed static plugins,
or compile needed modules into the library.
Info: creating super cache file /home/ivan/Qt5.4.0/5.4/Src/.qmake.superQt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /home/ivan/Qt5.4.0_StaticPrior to reconfiguration, make sure you remove any leftovers from
the previous build.@I ran the "make" command. But after 20 minites I saw this error: Project ERROR: Unknown module(s) in QT: dbus
@rm -f ../../lib/libQt5Gui.a
mv -f libQt5Gui.a ../../lib/
make[3]: Leaving directory/home/ivan/Qt5.4.0/5.4/Src/qtbase/src/gui' cd platformheaders/ && ( test -e Makefile || /home/ivan/Qt5.4.0/5.4/Src/qtbase/bin/qmake /home/ivan/Qt5.4.0/5.4/Src/qtbase/src/platformheaders/platformheaders.pro -o Makefile ) && make -f Makefile make[3]: Entering directory
/home/ivan/Qt5.4.0/5.4/Src/qtbase/src/platformheaders'
make[3]: Nothing to be done forfirst'. make[3]: Leaving directory
/home/ivan/Qt5.4.0/5.4/Src/qtbase/src/platformheaders'
cd platformsupport/ && ( test -e Makefile || /home/ivan/Qt5.4.0/5.4/Src/qtbase/bin/qmake /home/ivan/Qt5.4.0/5.4/Src/qtbase/src/platformsupport/platformsupport.pro -o Makefile ) && make -f Makefile
Project ERROR: Unknown module(s) in QT: dbus
make[2]: *** [sub-platformsupport-make_first] Error 3
make[2]: Leaving directory/home/ivan/Qt5.4.0/5.4/Src/qtbase/src' make[1]: *** [sub-src-make_first] Error 2 make[1]: Leaving directory
/home/ivan/Qt5.4.0/5.4/Src/qtbase'
make: *** [module-qtbase-make_first] Error 2@ -
Hello...can u tell the procedure for Qt5.5 statically on windows 7
-
Hello, i made all things how you said. The diffrence is only, i used Qt 5.3.2, Qt creator 3.2.1 and mingw...4.8.2.
Windows 7 ProfessionalI get some failure and I don't unterstand where they from.
YarrInterpreter.cpp:-1: Fehler: undefined reference to `JSC::Yarr::newlineCreate()'
YarrInterpreter.cpp:-1: Fehler: undefined reference to `JSC::Yarr::wordcharCreate()'
C:/Qt/Qt5.4.0_Static/lib/libQt5Qml.a(YarrInterpreter.o): bad reloc address 0x12 in section `.text$_ZN3WTF15BumpPointerPool6createEj[__ZN3WTF15BumpPointerPool6createEj]'
collect2.exe:-1: failure: error: ld returned 1 exit Status
can someone help me?
-
Hi and welcome to devnet,
IIRC, this comes from mis-generated files. You are probably missing python in your PATH
-
@SGaist
how can i repair this?Python is allready installed at --> "C:\Python34"
and Qt with static build is installed at --> "D:\sw_tools\Qt"What have i to do?
All failure during the mingw32-make and mingw32-make install which are mentioned by 8Observer8 are the same.
failure mingw32-make installAnother question is there a diffrence to use mingw which was installed with Qt or have I to use another Installation of mingw?
Thanks a lot for your help.
-
Re-run configure and restart the build
-
How did you modify PATH to include python ? Also, did you do a full rebuild ?
-
I don't modified any paths...
How above said, i modified only the qmake, made a backup of Src, start a configure --> mingw32-make and install
Than i undo the changes and set the kit...
By set the Qt Version and kit i get a yellow warning ...EDIT: @SGaist Thanks a lot!
I solved my Problem.
You have to include the path to python before configure your qmake.conf
so what i do:- modifed qmake.conf how mentioned by 8Observer8
- Start "Qt 5.4.0 for Desktop (MinGW 4.9 32 bit)"
- cd C:\Qt\Qt5.4.0\5.4\Src\
- now set the path to python.exe my Looks like --> C:\Python34
--> Print in the console --> set PATH=C:\Python34;%PATH% - choose your configuration and follow the instruction of 8Observer8
EDIT:
If you are going to compile one of your old projects, don't forget to remove the "*.pro.user" file otherwise there will be a failure with qmlimportscanner.exe