如何使我的可执行文件不依赖于 sfml dll 文件 [c++] [minGW] [g++]

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

也许我可以通过将它们链接到 exe 来“创建”这些必要的文件,并在程序启动时将它们存储在临时文件夹中,如果可能的话,请问如何?我试过乱用编译器选项,但似乎没有任何效果。

为了使您的可执行文件不依赖于 DLL 文件,您应该 link 它们是静态的。 SFML 通过使用他们的“sfml-xxx-s-d.lib”(用于调试)和“sfml-xxx-s.lib”(用于发布)库为您提供该选项,如文档中所述。

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.

注意:“xxx”代表您要包含到项目中的文件的名称

关于如何在 VisualStudio 中设置 SFML 的完整文档:https://www.sfml-dev.org/tutorials/2.5/start-vc.php

希望这能回答您的问题! :)