Why Qt needs to be configured with static parameter to create static build programs
-
Hi, I am a beginner in qt (also kind of a beginner in programming) and I have installed qt 5.6 on my computer using the installer (my computer is windows 7 and has msvc 2015 installed).
I want to create a portable program with only an .exe file that can run without any prior installation needed (I am making a joke program for a friend so I don't really want to bother her with installation and what not)
I wrote a very simple console application (I wanted to start with something easy) and after I build it, Qt Creator can run it but my windows 7 machine cannot (It says Qt5Cored.dll is missing).
I researched on the Internet on how to static build my program, and the instruction that I found said that I had to build Qt from scratch (and from source) while using the -static parameter on configure.
So my understanding is that I have to delete Qt, download the source, and than build it again? Isn't this a very lengthy approach? It seems to me very interesting that I have to actually build Qt with a different setting just to build my program statically. Is there an easy explanation for this?
My sources:
https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows
http://doc.qt.io/qt-5/windows-deployment.htmlA follow up question: After writing this program I also want to get into more serious software development which will probably not be a static build. Will it be possible to write normal programs without static linking if I configure Qt to be static?
-
Hi and welcome to devnet,
If you want a full static application then you have to also build all dependencies as static and since you're on Windows, you also have to take into account the Visual Studio Runtime (since you are using a Visual Studio Qt build). Note that this is nothing Qt specific.
No, you don't have to delete anything, you can use several builds of Qt in parallel without any problem. How fast your build time will be depends on the machine you have.
Developing applications and the type of builds are two completely unrelated topics.
Note that using a static build of Qt has licensing implications.