[Development] Qt Static Package

Carlos Enrique Pérez Sánchez ceperez1996 at gmail.com
Tue May 14 20:52:31 CEST 2019


Hello again!
I have some news concerning static builds.

*Let's start with WINDOWS:*
Note: Windows 10

I finally manage to build Qt for Windows statically. Even Qt Quick Controls
2 module was successfully built. The problem was (as pointed by *Thiago
Maicera*) the -qt-[...] bounded libraries. I use the default options and it
worked better than I expected.
I build Qt for both 32-bit and 64-bit architectures.

I installed:
Strawberry Perl 5.28.1.1
Python 2.7.14
DirectX SDK as provided by Microsoft

Strawberry Perl and Python added the appropriate folders to the PATH
environment variable: C:\Strawberry\c\bin, C:\Strawberry\perl\site\bin,
C:\Strawberry\perl\bin, C:\Python27\ and C:\Python27\Scripts. For the
DirectX SDK, I added the install path and the following folders: Include,
Libs/x86 and Utilities/bin/x86. Add the x64 folder instead of x86 if you
are targeting a 64-bit build.

The configure command line:
$ configure -prefix "X:/somePath/QtStatic" -static -static-runtime -release
-opensource -confirm-license -nomake tools -nomake examples -nomake tests
-skip qtwebengine -silent

There is no need to patch the qmake.conf file in your mkspec (as people
says) if you pass -static-runtime command line option to configure.
I use Qt Quick 2 Gallery Example as the test case, and in order to ensure
that the resulting application does not have any dependencies with the Qt
libraries, I installed a UNIX environment on Windows (by installing git)
and use the ldd tool.
For a 32-bit build, its output was:
    ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffc685f0000)
    ??? => ??? (0x77400000)
    wow64.dll => /c/Windows/System32/wow64.dll (0x7ffc658d0000)
    wow64win.dll => /c/Windows/System32/wow64win.dll (0x7ffc68540000)
Which is OK. No dependencies with Qt libraries.
For a 64-bit build, the output is a lot larger, but still it does not
depends of Qt libraries:
    ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff8ee110000)
    KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff8ec740000)
    KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff8ea360000)
    ADVAPI32.dll => /c/Windows/System32/ADVAPI32.dll (0x7ff8ec860000)
    msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff8ec570000)
    sechost.dll => /c/Windows/System32/sechost.dll (0x7ff8ec4c0000)
    RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ff8ec610000)
    GDI32.dll => /c/Windows/System32/GDI32.dll (0x7ff8ec410000)
    gdi32full.dll => /c/Windows/System32/gdi32full.dll (0x7ff8ea650000)
    msvcp_win.dll => /c/Windows/System32/msvcp_win.dll (0x7ff8ea7f0000)
    d3d9.dll => /c/Windows/SYSTEM32/d3d9.dll (0x7ff8caa50000)
    ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ff8ea1e0000)
    USER32.dll => /c/Windows/System32/USER32.dll (0x7ff8edf40000)
    ??? => ??? (0x30f0000)
    win32u.dll => /c/Windows/System32/win32u.dll (0x7ff8ea630000)
    ??? => ??? (0x140000)
    IMM32.dll => /c/Windows/System32/IMM32.dll (0x7ff8eb6f0000)
    SHELL32.dll => /c/Windows/System32/SHELL32.dll (0x7ff8ec910000)
    dxva2.dll => /c/Windows/SYSTEM32/dxva2.dll (0x7ff8d0ea0000)
    cfgmgr32.dll => /c/Windows/System32/cfgmgr32.dll (0x7ff8ea890000)
    combase.dll => /c/Windows/System32/combase.dll (0x7ff8ec0e0000)
    shcore.dll => /c/Windows/System32/shcore.dll (0x7ff8eb590000)
    bcryptPrimitives.dll => /c/Windows/System32/bcryptPrimitives.dll
(0x7ff8ea8e0000)
    windows.storage.dll => /c/Windows/System32/windows.storage.dll
(0x7ff8eabf0000)
    profapi.dll => /c/Windows/System32/profapi.dll (0x7ff8ea190000)
    powrprof.dll => /c/Windows/System32/powrprof.dll (0x7ff8ea110000)
    EVR.dll => /c/Windows/SYSTEM32/EVR.dll (0x7ff8cb650000)
    shlwapi.dll => /c/Windows/System32/shlwapi.dll (0x7ff8ec800000)
    bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7ff8ea600000)
    kernel.appcore.dll => /c/Windows/System32/kernel.appcore.dll
(0x7ff8ea170000)
    cryptsp.dll => /c/Windows/System32/cryptsp.dll (0x7ff8ea340000)
    WS2_32.dll => /c/Windows/System32/WS2_32.dll (0x7ff8eb520000)
    dwmapi.dll => /c/Windows/SYSTEM32/dwmapi.dll (0x7ff8e8b50000)
    ole32.dll => /c/Windows/System32/ole32.dll (0x7ff8eb720000)
    CRYPT32.dll => /c/Windows/System32/CRYPT32.dll (0x7ff8ea960000)
    OLEAUT32.dll => /c/Windows/System32/OLEAUT32.dll (0x7ff8ebf30000)
    MSASN1.dll => /c/Windows/System32/MSASN1.dll (0x7ff8ea1c0000)
    IPHLPAPI.DLL => /c/Windows/SYSTEM32/IPHLPAPI.DLL (0x7ff8e96a0000)
    MF.dll => /c/Windows/SYSTEM32/MF.dll (0x7ff8c7030000)
    NETAPI32.dll => /c/Windows/SYSTEM32/NETAPI32.dll (0x7ff8e3520000)
    RTWorkQ.DLL => /c/Windows/SYSTEM32/RTWorkQ.DLL (0x7ff8e26c0000)
    USERENV.dll => /c/Windows/SYSTEM32/USERENV.dll (0x7ff8ea010000)
    UxTheme.dll => /c/Windows/SYSTEM32/UxTheme.dll (0x7ff8e8720000)
    VERSION.dll => /c/Windows/SYSTEM32/VERSION.dll (0x7ff8e43f0000)
    WINMM.dll => /c/Windows/SYSTEM32/WINMM.dll (0x7ff8e6ef0000)
    WTSAPI32.dll => /c/Windows/SYSTEM32/WTSAPI32.dll (0x7ff8e6d20000)
    ODBC32.dll => /c/Windows/SYSTEM32/ODBC32.dll (0x7ff8c6f70000)
    WINMMBASE.dll => /c/Windows/SYSTEM32/WINMMBASE.dll (0x7ff8e6ec0000)
    ??? => ??? (0x140000)
    MFPlat.DLL => /c/Windows/SYSTEM32/MFPlat.DLL (0x7ff8e26f0000)
    DPAPI.DLL => /c/Windows/SYSTEM32/DPAPI.DLL (0x7ff8e9540000)
    CRYPTBASE.DLL => /c/Windows/SYSTEM32/CRYPTBASE.DLL (0x7ff8e9b70000)
    MFCORE.DLL => /c/Windows/SYSTEM32/MFCORE.DLL (0x7ff8b8230000)
    NETUTILS.DLL => /c/Windows/SYSTEM32/NETUTILS.DLL (0x7ff8e97b0000)
    ksuser.dll => /c/Windows/SYSTEM32/ksuser.dll (0x7ff8e6a50000)
    SRVCLI.DLL => /c/Windows/SYSTEM32/SRVCLI.DLL (0x7ff8e34f0000)

I also tested others applications that use Qt Multimedia and Qt Charts: all
OK.


*Now on LINUX:*
Note: KDE Neon based on Ubuntu 18.04

I installed the OpenGL dependencies mentioned in Qt Help. I also installed
python and perl.

My configure command line (almost the same used on Windows):
$ sudo ./configure -prefix "/somePath/Qt5Static" -platform linux-g++-64
-static -release -opensource -confirm-license -nomake tools -nomake
examples -nomake tests -skip qtwebengine -silent

The result is an application that does not have appropriate shaders for
QQC2 applications, and the ripple effect (Material Style) is broken (see
image bellow):
[image: Screenshot_20190506_153051.png][image:
Screenshot_20190506_153155.png]
The screenshoot shows the application running under the Material Style, but
the behavior is present on all styles.
Also, the cursor shown is no my desktop theme cursor (mine is black, and it
turns white and pixelated when I hover the application)

Output from $ ldd gallery:
linux-vdso.so.1 (0x00007ffd5bf54000)
libwayland-egl.so.1 => /usr/lib/x86_64-linux-gnu/libwayland-egl.so.1
(0x00007fe21417a000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fe213f72000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fe213d57000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fe213b2f000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007fe2138c7000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007fe213650000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe21344c000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007fe21323b000)
libEGL.so.1 => /usr/lib/x86_64-linux-gnu/libEGL.so.1 (0x00007fe213027000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1
(0x00007fe212de2000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6
(0x00007fe212b2e000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fe2128e1000)
libwayland-cursor.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-cursor.so.0
(0x00007fe2126d9000)
libwayland-client.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-client.so.0
(0x00007fe2124ca000)
libxkbcommon.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0
(0x00007fe21228b000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16
(0x00007fe212059000)
libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
(0x00007fe211dbb000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe211b9e000)
libicui18n.so.60 => /usr/lib/x86_64-linux-gnu/libicui18n.so.60
(0x00007fe2116fd000)
libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60
(0x00007fe211346000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
(0x00007fe21102f000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007fe210da3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007fe210b84000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007fe2107fb000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe21045d000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe210245000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe20fe54000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe215e8f000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fe20fc4d000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007fe20fa38000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fe20f834000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
(0x00007fe20f62e000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fe20f408000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007fe20f1fa000)
libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0
(0x00007fe20ef44000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fe20ed12000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0
(0x00007fe20ea8e000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fe20e886000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe20e67e000)
libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3
(0x00007fe20e451000)
libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60
(0x00007fe20c8a8000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe20c636000)
libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007fe20c405000)
liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fe20c1e9000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20
(0x00007fe20bece000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fe20bb96000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0
(0x00007fe20b981000)

After that, I rebuild Qt using -qt-[...] options:
./configure -prefix "/somePath/Qt5Static" -platform linux-g++-64 -static
-release -opensource -confirm-license -qt-pcre -qt-zlib -qt-freetype
-qt-xcb -qt-libpng -qt-libjpeg -qt-sqlite -nomake tools -nomake examples
-nomake tests -skip qtwebengine -silent

And the ldd output:
        linux-vdso.so.1 (0x00007fff287f4000)
        libwayland-egl.so.1 =>
/usr/lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f520a62d000)
        libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6
(0x00007f520a425000)
        libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6
(0x00007f520a20a000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1
(0x00007f5209fe2000)
        libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5
(0x00007f5209d6b000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5209b67000)
        libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2
(0x00007f5209956000)
        libEGL.so.1 => /usr/lib/x86_64-linux-gnu/libEGL.so.1
(0x00007f5209742000)
        libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3
(0x00007f52094f5000)
        libwayland-cursor.so.0 =>
/usr/lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f52092ed000)
        libwayland-client.so.0 =>
/usr/lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f52090de000)
        libxkbcommon.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0
(0x00007f5208e9f000)
        libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
(0x00007f5208c01000)
        libicui18n.so.60 => /usr/lib/x86_64-linux-gnu/libicui18n.so.60
(0x00007f5208760000)
        libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60
(0x00007f52083a9000)
        libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
(0x00007f5208092000)
        libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1
(0x00007f5207e06000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f5207be7000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007f520785e000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f52074c0000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007f52072a8000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5206eb7000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f520c463000)
        libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1
(0x00007f5206cb0000)
        libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0
(0x00007f5206a9b000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6
(0x00007f5206897000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
(0x00007f5206691000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5
(0x00007f520646b000)
        libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0
(0x00007f520625d000)
        libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8
(0x00007f5205ff5000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f5205dd8000)
        libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0
(0x00007f5205b22000)
        libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0
(0x00007f520589e000)
        libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6
(0x00007f5205696000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f520548e000)
        libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6
(0x00007f52051da000)
        libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3
(0x00007f5204fad000)
        libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60
(0x00007f5203404000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3
(0x00007f5203192000)
        libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0
(0x00007f5202f61000)
        liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1
(0x00007f5202d45000)
        libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20
(0x00007f5202a2a000)
        libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16
(0x00007f52027f8000)
        libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6
(0x00007f52024c0000)
        libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0
(0x00007f52022ab000)

Observe that the list is slighty shorter (48 vs 46), but it *shows the same
issues plus missing fonts*. I know that the last can be avoided by passing
-fontconfig to configure.

I am missing something here?
I installed gstreamer and the rest of libraries mentioned on the Qt Help
Center, and also other libraries (and its respective -dev packages) that
were shown during the dependencies checking in configure, but some of those
libraries are linked dinamically.

*Conclusions:*
Building Qt on Windows *is clearly documented* and *works as expected*.
Building Qt for Linux *is not clearly documented*, for example, most users
fail to compile Qt for Linux because they not specify the target mkspec
platform (which is no needed under Windows). That should be documented.
Also, there are too much dependences in the resulting static executable.


El mar., 30 abr. 2019 a las 2:08, Mitch Curtis (<mitch.curtis at qt.io>)
escribió:

> > -----Original Message-----
> > From: Simon Hausmann
> > Sent: Monday, 29 April 2019 5:58 PM
> > To: Mitch Curtis <mitch.curtis at qt.io>
> > Cc: Thiago Macieira <thiago.macieira at intel.com>; development at qt-
> > project.org
> > Subject: Re: [Development] Qt Static Package
> >
> >
> > The application is perfectly distributable, but the static libraries are
> tied to the
> > exact compiler binary and therefore not so suitable for sending to other
> > people. So it’s all good :)
> >
> > Simon
>
> Ah, thank you for clarifying!
>
> > On 29. Apr 2019, at 17:47, Mitch Curtis <mitch.curtis at qt.io> wrote:
> >
> > >> -----Original Message-----
> > >> From: Development <development-bounces at qt-project.org> On Behalf
> > Of
> > >> Thiago Macieira
> > >> Sent: Monday, 29 April 2019 5:18 PM
> > >> To: development at qt-project.org
> > >> Subject: Re: [Development] Qt Static Package
> > >>
> > >>> On Monday, 29 April 2019 00:27:14 PDT Mitch Curtis wrote:
> > >>> -static -release -ltcg -opensource -confirm-license -nomake tests
> > >>> -nomake examples -silent
> > >>
> > >> -static -ltcg is most definitely not redistributable. That build is
> > >> only usable in your exact machine, and only for so long as you don't
> > >> perform a system update.
> > >
> > > That's a pity. It shaved off 8 mb (19%) of my executable's size.
> > >
> > > Can you explain why it's not redistributable? I thought the whole
> point of
> > link time code generation was for release builds?
> > >
> > >> --
> > >> Thiago Macieira - thiago.macieira (AT) intel.com  Software Architect
> > >> - Intel System Software Products
> > >>
> > >>
> > >>
> > >> _______________________________________________
> > >> Development mailing list
> > >> Development at qt-project.org
> > >> https://lists.qt-project.org/listinfo/development
> > > _______________________________________________
> > > Development mailing list
> > > Development at qt-project.org
> > > https://lists.qt-project.org/listinfo/development
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190514/6771579a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot_20190506_153155.png
Type: image/png
Size: 84831 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190514/6771579a/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot_20190506_153051.png
Type: image/png
Size: 97287 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190514/6771579a/attachment-0003.png>


More information about the Development mailing list