Making static Build(standalone application) with Qt
You need to build Qt yourself from source. You will definitely want to maintain two builds of Qt. For debugging, you should use the shared build, as this has reasonable link times. For release, you should use the static build, definitely with link time code generation to keep the executable smaller, and expect the build of a trivial application to take on the order of a minute. This is because the "link" really generates machine code for both Qt and your application, and the code is specific to your application, thus making it generally perform better.
The way you do it without wasting disk space for multiple copies of the source is by using out-of-source Qt builds. So far the static Qt 5.1.1 build is broken, so the below only works for Qt 4, with Visual Studio.
Download the source to, say,
C:\Qt\4.8.5
.Create
C:\Qt\4.8.5-shared
. Open the visual studio console, CD there, and runC:\Qt\4.8.5\configure.exe -shared
with whatever other options you may have. Then build it usingnmake
orjom
.Create
C:\Qt\4.8.5-static
. Open the visual studio console, CD there, and runC:\Qt\4.8.5\configure.exe -static -ltcg
with whatever other options you may have. Then build it usingnmake
orjom
.
You'll need to link the plugins statically to your release build of the application.
Qt Creator makes it easy to use multiple builds of Qt in parallel. I routinely do builds using both Qt 4 and Qt 5, both static and shared, with local fixes to Qt 5 to get the static build to work.
Build Qt (static linking) for Visual Studio 2017 32bits
Looks good. My only remarks would be:
To remove gnuwin32 path as I don't see a reason why would you need it.
And consider making a shadow build to keep Qt sources unpolluted.
set _SHADOW_DIR="C:\build_static"
set _SOURCE_DIR="C:\SrcQt5.9.1"
...
cd %_SHADOW_DIR%
call %_SOURCE_DIR%\configure ...
Qt 5.6 msvc static compile
its work here:
install python v2.7
start menue -> all programs -> visual studio 2013 -> visual studio tools
open Developer Command Prompt for VS2013
in command line:
set QMAKESPEC=win32-msvc2013
set QTDIR=C:\Qt\QT-EVE~1.0\qtbase
set PATH=C:\Qt\QT-EVE~1.0\qtbase\bin;%PATH%
set PYTHONPATH=%C:\Python27%;C:\Python27\Lib
cd C:\Qt\qt-everywhere-opensource-src-5.6.0
configure -static -platform win32-msvc2013 -nomake examples -nomake tests
c or o
nmake
Related Topics
Why "Long Int" Has Same Size as "Int"? Does This Modifier Works at All
How to Debug C++11 Code with Unique_Ptr in Ddd (Or Gdb)
Template Specialization for Multiple Types
Should Function Declarations Include Parameter Names
Can You Make a Computed Goto in C++
Linux Serial Port Reading - How to Change Size of Input Buffer
How to Initialize All Tuple Elements by the Same Arguments
Reading from .Txt File into Two Dimensional Array in C++
C++11 Random Number Distributions Are Not Consistent Across Platforms -- What Alternatives Are There
Cross-Platform C++: Use The Native String Encoding or Standardise Across Platforms
What Does the |= Operator Mean in C++
C++ Is It Necessary to Delete Dynamically Allocated Objects at the End of the Main Scope
C++ Two Libraries Depend on Same Lib But Different Versions
Why Is My Class Non Default-Constructible
Rotating a 2D Pixel Array by 90 Degrees
Why Are Override and Final Identifiers with Special Meaning Instead of Reserved Keywords