Skip to content

Mingw full static linkage instead of binary

Linking MinGW binaries fully statically with CMake to drop the libgcc_s_seh-1.dll and libstdc++-6.dll runtime dependencies from your Windows build.

Alexey Kasyanchuk1 min read

How do you avoid depending on libgcc_s_seh-1.dll or libgcc_s_dw2-1.dll? You need to add the following link flags:

-static-libgcc -static-libstdc++ -static

In the case of CMake:

if(MINGW)
    SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -static")
endif()