Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to statically link Qt on Windows w Visual Studio 2017
mjsmithers last edited by mjsmithers
I've just purchased the QT commercial license and my (maybe naive) understanding was that when Qt installed under this license, static linking would be as simple as adding "CONFIG += static" into the project .PRO file, however this doesn't work. (The build defaults to dynamic linking, which does work but requires running windeployqt.exe.) "QMAKE_LFLAGS = -MT" doesn't help with static linking either.
Can anyone - preferably commercial license holders - point me in the right direction? I'm using Visual Studio 2017 with the QT plugin, and Qt versions 5.9.5 and newer.
Many pages talk about first rebuilding Qt with static options. E.g.
They refer to running "configure" however my PC (which includes MSVC2017 and QT) only has some "configure.prf" files in some QT mkspecs\features directories. There aren't any configure.exe or configure.bat files.
mjsmithers last edited by
Ok, after running the Qt maintenance tool again and downloading the Src directory for Qt 5.9.5, I found the "configure.bat" file in c:\Qt\5.9.5\Src.
I then started the Visual Studio 2017 Command Prompt, changed to the c:\Qt\5.9.5\Src directory and ran
configure -static -release -platform win32-msvc
The bat file prompted me for a few extra things, such as licensing.
When the script finished, I ran
only to have the build fail at ioutils.cpp with a path problem.
Turns out c:\Qt\5.9.5\Src\bin\qt.conf had unix paths, instead of Windows paths, so I changed the three Prefix lines to C:\Qt\5.9.5 and restarted nmake.
So far the build is working.