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 run C:\Qt\4.8.5\configure.exe -shared
with whatever other options you may have. Then build it using nmake
or jom
.
Create C:\Qt\4.8.5-static
. Open the visual studio console, CD there, and run C:\Qt\4.8.5\configure.exe -static -ltcg
with whatever other options you may have. Then build it using nmake
or jom
.
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.