Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Use the -static flag when linking the C++ runtime static  (Read 1170 times)

0 Members and 1 Guest are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9658
    • View Profile
    • development blog
    • Email
Use the -static flag when linking the C++ runtime static
« on: July 15, 2016, 02:10:18 pm »
More than 2.5 years ago I've already once made a pull request 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

 

anything