简体   繁体   English

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

[英]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?也许我可以通过将它们链接到 exe 来“创建”这些必要的文件,并在程序启动时将它们存储在临时文件夹中,如果可能的话,请问如何? I've tried messing around with compiler options but nothing seems to work.我试过弄乱编译器选项,但似乎没有任何效果。

In order your executable to not rely on DLL files, you should link them statically.为了您的可执行文件不依赖于 DLL 文件,您应该静态链接它们。 SFML gives you that option by using their "sfml-xxx-sd.lib" (for Debug) and "sfml-xxx-s.lib" (for Release) libraries, as stated in the documentation. SFML 通过使用他们的“sfml-xxx-sd.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.如果您想摆脱这些 DLL 并将 SFML 直接集成到您的可执行文件中,您必须链接到静态版本。 Static SFML libraries have the "-s" suffix: "sfml-xxx-sd.lib" for Debug, and "sfml-xxx-s.lib" for Release.静态 SFML 库具有“-s”后缀:“sfml-xxx-sd.lib”用于调试,“sfml-xxx-s.lib”用于发布。 In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.在这种情况下,您还需要在项目的预处理器选项中定义 SFML_STATIC 宏。

NOTE: "xxx" stands for the name of the file you are trying to include into your project注意:“xxx”代表您尝试包含到项目中的文件的名称

Full documentation on how to set up SFML in VisualStudio: https://www.sfml-dev.org/tutorials/2.5/start-vc.php关于如何在 VisualStudio 中设置 SFML 的完整文档: https ://www.sfml-dev.org/tutorials/2.5/start-vc.php

Hope this answered your question!希望这回答了您的问题! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM