Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to statically link a Qt application on windows?
I need to send out my application for testing and of course it requires Qt5Widget.dll plus others. I can't figure out how to simply link the executable to static libraries?
I am following http://doc.qt.io/qt-5/windows-deployment.html but I am find the documentation lacking.
bq. cd C:\path\to\Qt
configure -static <any other options you need>
But c:\Qt is a root folder (default in my case) and configure command is not recognized. I went to c:\Qt\5.3 and still the same case. Also what am I suppose to fill for < <any other options you need> if anything? (I am not not filling it and hope it doesn't mess up)
First why do we have to go command line just to link statically? I also saw may I need to add this line to .pro file
@CONFIG += static@
But this doesn't do anything as well.
How do I link statically?
Do you want to link to Qt statically? If so, you need to build a static version of Qt.
Is that what need to do? I am coming from VS2010 world and it was a simple settings in my project to link dynamic or statically. But yes I want to link libraries statically (most easy way to distribute exe without sending the dlls). How do I build static version of Qt?
"Statically linking a Qt application" does not mean "linking to statically built Qt". You wanted to ask about the latter, but your wording meant the former.
If you have a library built both as a dynamic and static library than the only thing you have to do is to change the LIBS += line in your pro file so that you link with the library of your choice. That's that easy with qmake. This is called linking to a static or dynamic library.
But this is not what you are asking. You want to link to a statically built Qt. The thing is that the Qt SDK you have downloaded from qt-project.org does not contain statically built Qt libraries. You have to do that yourself. Make sure that your application is properly licensed if you want your application to link to statically built Qt.
Building Qt on Windows is explained "here":http://doc.qt.io/qt-5/windows-support.html#building-qt-5-from-source.
No I am asking the former, I only want to link to static library so the LIBS + line should do but what libs do I include in pro file? My application is already running fine so assume it knows which library to link against, how do I change that from dynamic to static link? Thanks.
Which static library? Qt? If yes, you have to build it yourself. It is not available in the Qt SDK. I have already provided the link for building Qt on Windows.