Method for Static Compile with the MSYS2 Toolchain
The advantage of static compilation is that you don’t need to include a bunch of dynamic link libraries when publishing. In theory, the Msys2 toolchain supports static compilation, but in practice, even if you directly add the
-static flag, the generated executable still reports missing dynamic link libraries at runtime, especially the three libraries required by the Mingw toolchain: libwinpthread-1.dll, libstdc++-6.dll, and libgcc_s_seh-1.dll. For the clang compiler, the runtime dependency becomes libc++.dll. This article explores a simple method to facilitate static link compilation management for different compilers.
4 minutes to read
Andrew Moa