Creating a static assembly (stand-alone application) with Qt

I started with Qt a while ago. I downloaded the 32-bit version of Windows (666mB), and nothing more. I made a simple calculator application. The application starts when I launch it from the creator of Qt, but the built-in exe shows that the DLL is missing. I don’t want to use walker dependencies. I want to create a static assembly (I read about it, but I cannot run it)

My goal is to make a fully functional calculator (without installation), without the need to manually add dependencies. I read about configure -static, but I did not understand how to use it. Thanks in advance for your help.

+6
source share
1 answer

You need to build Qt yourself from the source. You will definitely want to keep two Qt assemblies. For debugging you should use the general assembly, as this has reasonable link times. For release, you should use a static assembly, specifically with generation of communication time code, to reduce the executable and expect that assembling a trivial application will take about a minute. This is because the β€œlink” does generate native code for Qt and your application, and the code is specific to your application, which makes it generally more efficient.

As you do this, without losing disk space for multiple copies of the source, use the built-in Qt assemblies outside the source. So far, the static Qt 5.1.1 line has been broken, so the following works only for Qt 4 with Visual Studio.

  • Download the source, say C:\Qt\4.8.5 .

  • Create C:\Qt\4.8.5-shared . Open the visual studio console, there is a CD and run C:\Qt\4.8.5\configure.exe -shared with any other parameters that you may have. Then build it with nmake or jom .

  • Create C:\Qt\4.8.5-static . Open the visual studio console, there is a CD and run C:\Qt\4.8.5\configure.exe -static -ltcg with any other parameters that you may have. Then build it with nmake or jom .

You need to bind plugins statically to your application build version .

Qt Creator makes it easy to use multiple Qt assemblies in parallel. I usually build using both Qt 4 and Qt 5, both static and general, with local fixes for Qt 5 to make the static build work.

+8
source

Source: https://habr.com/ru/post/954335/


All Articles