2
votes

I want to build Qt 5.10.1 using MSVC2015, and without MSVC Runtime. Followed http://amin-ahmadi.com/2016/09/22/how-to-build-qt-5-7-statically-using-msvc14-microsoft-visual-studio-2015/

  1. Configure:

configure -static -debug-and-release -prefix "C:\Qt\5.10.1-static-msvc2015" -platform win32-msvc2015 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-sqlite -sql-odbc -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests

  1. modified src\qtbase\mkspecs\common\msvc-desktop.conf change -MD to -MT.

No error during building, but if I don't install MSVC runtime when I run my program will get:

api-ms-win-crt-runtime-l1-1-0.dll missing.

How to make the MSVC static standalone like Mingw static build?

The output of compiling test program:

cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MT -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -D_UNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_MULTIMEDIA_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DNDEBUG

If I don't do step 2, the output will be -MD.

So Why the -MT (step 2) didn't work?

If you having any idea or guessing, Please comment.

Update:

  1. Win10 64

No matter I add -static-runtime or not, both can run with without vc_redist

  1. Win 7 32

Qt 5.10.1 compilation passed, but got api-ms-win-core-winrt-l1-1-0.dll is missing when executing the program.

Even I reinstall vc_redist still got the error...

Relate: Why installed vc_redist still gives api-ms-win-core-winrt-l1-1-0.dll is missing

Qt 5.11.1 compilation also passed, but got C1083: 'QtCore/qglobal.h':No such file or directory when building the program.

1

1 Answers

2
votes

Compiling Qt sources from Qt 5.5.0 you can pass -static-runtime argument to configure for static runtime.

Changes 5.5.0:

[Windows] Added -static-runtime option.

Config Options:

-static-runtime ...... With -static, use static runtime [no] (Windows only)