Search code examples
c++g++mingwsfml

how to make my executable not rely on sfml dll files [c++] [minGW] [g++]


Perhaps I can "create" these necessary files by having them linked to the exe, and store them in a temp folder when the program launches, and if that's possible how please? I've tried messing around with compiler options but nothing seems to work.


Solution

  • In order your executable to not rely on DLL files, you should link them statically. SFML gives you that option by using their "sfml-xxx-s-d.lib" (for Debug) and "sfml-xxx-s.lib" (for Release) libraries, as stated in the documentation.

    If you want to get rid of these DLLs and have SFML directly integrated into your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release. In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.

    NOTE: "xxx" stands for the name of the file you are trying to include into your project

    Full documentation on how to set up SFML in VisualStudio: https://www.sfml-dev.org/tutorials/2.5/start-vc.php

    Hope this answered your question! :)