title: How to force libraries to link statically in qt creator
body: <p>When one wants to link statically all available libraries using g++,
  this person passes <strong>-static</strong> flag to the compiler.</p>
  
  <p>But how to do it from Qt Creator?</p>
  
  <p>Firstly, I tried this advice:
  <a href="https://stackoverflow.com/questions/20799161/how-to-make-qt-and-qtcreator-link-the-libraries-statically-instead-of-dynamic">How to make Qt and Qtcreator link the libraries statically instead of dynamic?</a></p>
  
  <p>The post suggests to use </p>
  
  <pre><code>CONFIG += static
  </code></pre>
  
  <p>But that just doesn't work.</p>
  
  <p>Secondly, I tried another approach and added the following line to my .pro file:</p>
  
  <pre><code>QMAKE_CXXFLAGS += -static 
  </code></pre>
  
  <p>That didn't solve the problem either.
  I analyzed compiler output and discovered:</p>
  
  <p>-static flag is added only when compiling sources to object files.
  But when building executable, this flag is absent.</p>
  
  <p>Here are the exact compiler commands that I copied from the compiler output tab:</p>
  
  <pre><code>g++ -c -pipe -fno-keep-inline-dllexport -static -g -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -I..\..\..\ASSETS\PROG_CPP\MY_CPP\2016\test -I. -I..\..\..\icu\dist\include -I..\..\5.7\mingw53_32\mkspecs\win32-g++  -o debug\main.o ..\..\..\ASSETS\PROG_CPP\MY_CPP\2016\test\main.cpp
  g++ -Wl,-subsystem,console -mthreads -o debug\test.exe debug/main.o  -LC:\icu\dist\lib -lsicuio -lsicuin -lsiculx -lsicule -lsicuuc C:\icu\dist\lib\sicudt.a -lpthread -lm
  </code></pre>
  
  <p>How to force Qmake to add -static to all commands?</p>