[Interest] I can´t compile Qt statically (statically link)

Nuno Santos nunosantos at imaginando.pt
Mon Jan 16 20:06:28 CET 2017


Ernesto,

I have been able to compile Qt statically on Windows since version 5.6. One thing that have I found is that having the right environment is crucial.

I usually open a Visual Studio command prompt and then I run a bat with the following content (currently for 5.8 32 bit)

REM Set up \Microsoft Visual Studio 2015, where <arch> is \c amd64, \c x86, etc.
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
SET _ROOT=C:\Qt\5.8\src\
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%;c:\python27\
REM Uncomment the below line when using a git checkout of the source repository
REM SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
SET QMAKESPEC=win32-msvc
SET QMAKE_MSC_VER=1900
SET _ROOT=


> On 16 Jan 2017, at 03:05, Ernesto <ernestoac at icrt.cu> wrote:
> 
> 
> 
> Hello everyone,
> Now I´m blocked trying to (statically link) compile Qt statically (I´m using Qt 5.5.0) to runs my applications without Qt and others libraries. I did the following:
>  
> First I went to C:\Qt\Qt5.5.0\5.5\mingw492_32\mkspecs\win32-g++\ and edited qmake.conf
> I put in QMAKE_LFLAGS something like this:
> QMAKE_LFLAGS            = -static -enable-stdcall-fixup -wl,-enable-auto-import -wl,-enable-runtime-pseudo-reloc
>  
> Next I opened the Qt console
> So configure command doesn´t work, I have to change the default path for Qt console (C:\Qt\Qt5.5.0\5.5\mingw492_32) to C:\Qt\Qt5.5.0\5.5\Src\qtbase because configure.exe doesn´t exist in mingw492_32 folder, it is in qtbasefolder.
>  
> So I enter 
> configure -platform win32-g++ -static –release
>  
> And the last lines of output was:
> Creating qmake...
> mingw32-make: Nothing to be done for 'first'.
> Running configuration tests...
> WARNING: The DirectX SDK could not be detected:
>   There is no Direct X SDK installed or the environment variable "DXSDK_DIR" is not set.
> Disabling the ANGLE backend.
> WARNING: Using OpenGL ES 2.0 without ANGLE.
> Specify -opengl desktop to use Open GL.
> The build will most likely fail.
> (Press any key to continue...)
>  
> When I press any key, runs and I get this:
> Qt is now configured for building. Just run mingw32-make.
> To reconfigure, run mingw32-make confclean and configure.
>  
> And later I type mingw32-make sub-src and I wait with patience. Several minutes later I get that:
> Makefile:34: recipe for target 'release' failed
> mingw32-make[2]: *** [release] Error 2
> mingw32-make[2]: Leaving directory 'c:/Qt/Qt5.5.0/5.5/Src/qtbase/src/tools/qlalr'
> Makefile:188: recipe for target 'sub-qlalr-make_first' failed
> mingw32-make[1]: *** [sub-qlalr-make_first] Error 2
> mingw32-make[1]: Leaving directory 'c:/Qt/Qt5.5.0/5.5/Src/qtbase/src'
> makefile:38: recipe for target 'sub-src' failed
> mingw32-make: *** [sub-src] Error 2
>  
> Return to my Project file (.pro) and add the following line of code:
> CONFIG += static
>  
> When I compile the Project its show me this errors:
> :-1: error: error: unrecognized command line option '-wl,-enable-auto-import'
> :-1: error: error: unrecognized command line option '-wl,-enable-runtime-pseudo-reloc'
>  
> I went to qmake.conf file of the beginning and delete this two arguments, it will result like this:
> QMAKE_LFLAGS            = -static -enable-stdcall-fixup
>  
> I compile and:
> :-1: warning: cannot find entry symbol nable-stdcall-fixup; defaulting to 00401000
>  
> So again I delete this args, resulting:
> QMAKE_LFLAGS            = -static
>  
> When I compile at this point, Qt says me (xxx is the rest of project absolute path):
> Starting xxx\release\DynamicLink.exe...
> xxx\release\DynamicLink.exe exited with code 1989883493
>  
> And doesn´t shows my MainWindows.
>  
>  
> Regards for all,
> Ernesto
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org <mailto:Interest at qt-project.org>
> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170116/5cd8915e/attachment.html>


More information about the Interest mailing list