I would like to be able to use mingw-w64 to build binaries that link to the Universal CRT available with Visual Studio 2015+ instead of MSVCRT.lib. The release notes for mingw-w64 v6.0.0 include the following: "Massive additions to support UCRT thanks to Martin Storsjö"
Unfortunately my searches have not revealed the documentation on how to use this support.
Does anyone know what options I need to supply and where to supply them?
Well, I have done it along with VS 2017. But as far as I understand both VS 2015 and VS 2017 use the VCRUNTIME140.DLL
, so no worries here.
It is divided into two steps:
VCRUNTIME140.DLL
:This is done by doing the following:
mkdir scratch; cd scratch
cp C:/Windows/System32/vcruntime140.dll .
dumpbin /exports vcruntime140.dll > exports.txt
echo LIBRARY VCRUNTIME140 > vcruntime140.def
echo EXPORTS >> vcruntime140.def
tail +20 exports.txt | head -n -10 | awk '{print $4}' >> vcruntime140.def
lib /def:vcruntime140.def /out:libvcruntime140.a /machine:x86
cp libvcruntime140.a $(MINGW_ROOT)/i686-w64-mingw32/lib
VCRUNTIME140
and UCRT
instead of MSVCRT
gcc -dumpspecs > $(MINGW_ROOT)/lib/gcc/i686-w64-mingw32/$(GCC_VERSION)/specs
-D_UCRT
to cpp
and cc1plus
sections of the specs file. This will prevent undefined references linking errors for the scanf
functions family. Check my other question.-lmsvcrt
to -lvcruntime140 -lucrt
in the libgcc
section of the specs file.Please exchange $(MINGW_ROOT)
with the location of where u have MinGW.
Notes:
i686-w64-mingw32
, within the paths I included may differ for your case. I believe based on the architecture. So you may have to modify that accordingly.libucrt.a
in the $(MINGW_ROOT)/i686-w64-mingw32/lib folder. I am using MinGW 7.0.0 with GCC 7.4.0.