SFML community forums

General => Feature requests => Topic started by: eXpl0it3r on July 15, 2016, 02:10:18 pm

Title: Use the -static flag when linking the C++ runtime static
Post by: eXpl0it3r on July 15, 2016, 02:10:18 pm
More than 2.5 years ago I've already once made a pull request (https://github.com/SFML/SFML/pull/487) for this, but we decided to close it. However since this is still quite an annoyance of manually changing compiler flags whenever I build SFML (statically), I thought maybe it was worth addressing again.

Currently when you choose SFML_USE_STATIC_STD_LIBS in CMake, the CMake script will link libstdc++ and libgcc statically, so you won't have to provide these two DLLs. However, when you use a compiler that uses another runtime library it won't be linked statically and you'll have to provide the DLL as well. This is especially true with all the latest MinGW-w64 builds which use winpthreads for std::thread. What I've been doing for the past few years is adding -static to the C++ linker flags, which in turn will also link the winpthread library statically and I don't have to ship any DLLs. But every so often I forget to add it in the first place and thus have to build SFML again.

On the PR we had once the concern that -static would mean that the linker would try to link everything statically. I've never had any issues with it, as such I don't really see a disadvantage in using it, unless someone can point out some possible problem.