[cfe-dev] Compile Compact C Compiler from Clang on Windows 10. For Use with Lua

Martin Storsjö via cfe-dev cfe-dev at lists.llvm.org
Sun Jan 19 23:13:27 PST 2020


Hi,

On Sun, 19 Jan 2020, Russell Haley wrote:

> You may have answered a question I've had for some time: "Does mingw require
> a redistributable"? It sounds like the answer is "whenever linking to
> non-standard Windows API calls". If that's the case, how does one get that
> redistributable and/or know when it's required?

In general, mingw doesn't require extra redistributables.

The full answer is more like this:

Mingw does (as mentioned before) provide a few extra nonstandard APIs like 
usleep, getopt and maybe a few others. These are always statically linked 
into your executable and doesn't impose any extra redistributable 
components. Mingw also statically links a few other bits, primarily a 
varied set of reimplementations of math functions, as the default linked 
msvcrt.dll doesn't provide all C99 math functions, and not all of the ones 
that are provided are fully C99 compliant.

There used to be a separate redistributable dll that had to be linked and 
included for some thread specific initialization, but that's not 
required/used in modern times, at least not when using the mingw-w64 fork 
(which I'm using).

If you build C++ code, you'll end up with a dependence on a separate DLL 
for the C++ standard library, but you can either add -static when linking, 
or remove libc++.dll.a, to avoid linking it dynamically and instead 
statically linking it into each module.

If using a GCC based mingw setup (e.g. like the ones from 
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/), 
you can also get libgcc linked dynamically, but you can overcome that in 
the same way as above, with either -static or -static-libgcc. My 
toolchains use compiler_rt instead of libgcc, and that's always linked 
statically.

// Martin



More information about the cfe-dev mailing list