Fixing Static Building of Qt SDK 4.7.1 or later, under Windows



  • Hi to all.

    Static Building of Qt SDK, versions 4.7.1 and later, as described in http://doc.trolltech.com/4.7.1/deployment-windows.html#static-linking , is not working.

    It works OK, for Qt SDK up to version 4.7.0, which is the one I am using, because of this.

    Are there any plans for fixing it?



  • Can you provide a link to an official statemant about static linking not working? Inside the link you mentioned I can not see a statement like this.



  • I tried it myself and it failed, for Qt SDK >= 4.7.1, under Windows 7.

    Qt SDK 4.7.0. builds OK.

    Has it worked for you?


  • Moderators

    What exactly fails? Have you "filed a bug report":http://bugreports.qt.nokia.com/ ? If this is indeed a bug, then mentioning it in the forum will not get it fixed!



  • I strongly recommend to build your static Qt libs not from the SDK but from the vanilla source tarball. You can download it from the resources link on DevNet.



  • bq. I strongly recommend to build your static Qt libs not from the SDK but from the vanilla source tarball.

    Be careful to take the .zip file and not the .tar.gz since you are running on windows. The versions differ only by line endings, but the configure script will complain in a cryptic way when you pick the wrong package.



  • Thanks fellows, I will give the vanilla sources of Qt 4.7.3 a try. :-)



  • I built a static 4.7.3 from the sources using VS2008 on a 64-bit Windows 7 machine without any problems. If you're using shadow building, it's probably a good idea to skip the examples, though (using the -nomake examples configure option). Shadow building is nice, because it lets you build all your different builds from the same source tree - and whenever a build fails, you can start it over again without having to unpack a fresh source tree again.



    1. I installed Qt SDK 4.7.3 to its default directory C:\QtSDK.
    1. Extracted the vanilla sources of Qt Library 4.7.3 (http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.zip) to

    C:\qt-everywhere-opensource-src-4.7.3

    1. I ran the Qt Command Prompt (with "Run as Administrator" option),

    and cded to C:\qt-everywhere-opensource-src-4.7.3

    1. configure -static -release -platform win32-g++ -nomake examples

    succeeded.

    1. mingw32-make was building without problem for about 3 hours, when it failed with these messages:

    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
    oc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o ....\bin\qmlviewer.exe object
    _script.qmlviewer.Release -L"c:\qt-everywhere-opensource-src-4.7.3\lib" -L"c:\q
    t-everywhere-opensource-src-4.7.3\lib" -lmingw32 -lqtmain -lQtDeclarative -lQtOp
    enGL -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lglu32 -lopengl32 -lQtGui -lgdi
    32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtNetwork -lQtCo
    re -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qpaintengineex_opengl2.o
    ):qpaintengineex_opengl2.cpp:(.text+0x11c0): undefined reference to _imp___Z16q t_imageForBrushib' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qpaintengine_opengl.o):q paintengine_opengl.cpp:(.text+0xacda): undefined reference to_imp___Z16qt_imag
    eForBrushib'
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qpixmapdata_gl.o):qpixma
    pdata_gl.cpp:(.text+0xcd): undefined reference to _imp___Z14qt_defaultDpiXv' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qpixmapdata_gl.o):qpixma pdata_gl.cpp:(.text+0xe1): undefined reference to_imp___Z14qt_defaultDpiYv'
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qpixmapdata_gl.o):qpixma
    pdata_gl.cpp:(.text+0xfa): undefined reference to _imp___Z14qt_defaultDpiYv' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qpixmapdata_gl.o):qpixma pdata_gl.cpp:(.text+0x13a): undefined reference to_imp___Z14qt_defaultDpiXv'
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixmapfilter.o):qglpi
    xmapfilter.cpp:(.text+0x1842): undefined reference to _imp___Z13qt_halfScaledRK 6QImage' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixmapfilter.o):qglpi xmapfilter.cpp:(.text+0x1b3b): undefined reference to_imp___Z13qt_halfScaledRK
    6QImage'
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixmapfilter.o):qglpi
    xmapfilter.cpp:(.text+0x1e19): undefined reference to _imp___Z12qt_blurImageR6Q Imagedbi' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixmapfilter.o):qglpi xmapfilter.cpp:(.text+0x26ff): undefined reference to_imp___Z12qt_blurImageR6Q
    Imagedbi'
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixmapfilter.o):qglpi
    xmapfilter.cpp:(.text+0x2e1e): undefined reference to _imp___Z13qt_halfScaledRK 6QImage' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixmapfilter.o):qglpi xmapfilter.cpp:(.text+0x2efc): undefined reference toimp___Z17qt_memrotate90
    glPKjiiiPji'
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglframebufferobject.o):
    qglframebufferobject.cpp:(.text+0x53f): undefined reference to _imp___Z14qt_def aultDpiXv' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglframebufferobject.o): qglframebufferobject.cpp:(.text+0x569): undefined reference to_imp___Z14qt_def
    aultDpiYv'
    c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixelbuffer.o):qglpix
    elbuffer.cpp:(.text+0x20b): undefined reference to _imp___Z14qt_defaultDpiXv' c:\qt-everywhere-opensource-src-4.7.3\lib/libQtOpenGL.a(qglpixelbuffer.o):qglpix elbuffer.cpp:(.text+0x235): undefined reference to_imp___Z14qt_defaultDpiYv'
    collect2: ld returned 1 exit status
    mingw32-make[3]: *** [....\bin\qmlviewer.exe] Error 1
    mingw32-make[3]: Leaving directory C:/qt-everywhere-opensource-src-4.7.3/tools/ qml' mingw32-make[2]: *** [release] Error 2 mingw32-make[2]: Leaving directoryC:/qt-everywhere-opensource-src-4.7.3/tools/
    qml'
    mingw32-make[1]: *** [sub-qml-make_default-ordered] Error 2
    mingw32-make[1]: Leaving directory `C:/qt-everywhere-opensource-src-4.7.3/tools'

    mingw32-make: *** [sub-tools-make_default-ordered] Error 2

    C:\qt-everywhere-opensource-src-4.7.3>

    What am I doing wrong? Thank you a lot.



  • Hi,

    There are some fixes for static building that didn't make it into the 4.7.3 release. The patches are used by mingw-cross-env, a project focused on cross building static static libraries.

    The project is here http://mingw-cross-env.nongnu.org/.

    If you just want the patches, they are here:
    http://hg.savannah.gnu.org/hgweb/mingw-cross-env/file/1de8581a1adf/src/qt-1-cherrypicks.patch

    Mark



  • Hi Mark,

    I am having same issue as Ioannis Vranos, I am using QT SDK 3.7.3. How do I apply the patches you mentioned?

    Thanks!



  • Hi,

    I build teh static version of Qt 4.7.1 like in this "described wiki article":http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc . For me it worked with MinGW. The problem is that some modules do not support static building anymore without changing a bit. But afterwards it worked perfectly.



  • Gerolf,

    In the editing config files are you suppose to add the bold lines in or replace the existing lines in the config files? Also, what does the "..." in "LFLAGS = -static -static-libgcc …" mean, is to represent that there should something after it?

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.