abdallah allam abdallah allam - 29 days ago 7x
C++ Question

What after build Qt to get static application?

what after build Qt 5.6 msvc to get static deployment, i had done built Qt successful (configure -static -platform win32-msvc2013 -nomake examples -nomake tests) about 4 hour, and i opened a new project and but in .pro CONFIG += static and switched to relase mode and get error that libraries is missing, its normal widget, when run exe from relase folder its size is small about 20 kb, is there step missing?


Don't add CONFIG += static to the project, it is not necessary. The same PRO file can work with either a dynamic or static Qt build, which is convenient, since you can use the faster to compile and capable of debugging dynamic build for development, and only use the static build for final production.

After your static build is completed, you need to add it to a kit, and add the to your project:

  • open Tools - Options - Build & Run
  • from "Qt Versions" click Add... and select your build's bin\qmake.exe
  • from "Kits" use Add or Clone to create a new kit, select the static Qt build, the compiler and so on
  • from "Projects" (the wrench icon to the left of Qt Creator) - Add Kit, then select your kit
  • from the button above the Run button (the green arrow below Projects) select your kit and release

enter image description here

enter image description here

That's about it... if your build is OK your app should build and run.

Keep in mind that if you distribute closed source applications build statically you need to provide your object files and information about the used tools and versions to satisfy the requirement of LGPL about providing an option to re-link your application against a different version of the library. That's assuming you don't own a commercial Qt license.