在 CodeLite 中链接 SFML

Linking SFML in CodeLite

好的,我正在尝试 link CodeLite 项目中的 SFML,但没有成功。那我做了什么:

  1. 将 SFML 的包含文件夹添加到 CodeLite 的 IncludePaths。
  2. 将 SFML 的 lib 文件夹添加到 CodeLite 的 LibrariesSearchPath。
  3. 在 CodeLite 中添加了 SFML_STATIC 预处理器。

  4. 像这样将库添加到 LinkerOptions:

    sfml-graphics;sfml-window;sfml-audio;sfml-network;sfml-system
    
  5. 将 5 个 dll(sfml-graphics-2.dll.. 等)添加到调试文件夹和项目文件夹

这是构建日志: C:\WINDOWS\system32\cmd.exe /C ""E:/Program Files (x86)/CodeBlocks/MinGW /bin/mingw32-make.exe" -j4 SHELL=cmd.exe -e -f Makefile"" "----------Building project:[ Test - Debug ]----------" mingw32-make.exe[1]: Entering directory 'F:/Dropbox/Programming/OpenGL/Test' "E:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe" -o ./Debug/Test @"Test.txt" -L. -LF:/Dropbox/Programming/SFML/SFML-2.3.2x86/lib sfml-graphics sfml-window sfml-audio sfml-network sfml-system g++.exe: error: sfml-graphics: No such file or directory g++.exe: error: sfml-window: No such file or directory g++.exe: error: sfml-audio: No such file or directory g++.exe: error: sfml-network: No such file or directory g++.exe: error: sfml-system: No such file or directory mingw32-make.exe[1]: *** [Debug/Test] Error 1 Test.mk:78: recipe for target 'Debug/Test' failed mingw32-make.exe[1]: Leaving directory 'F:/Dropbox/Programming/OpenGL/Test' mingw32-make.exe: *** [All] Error 2 Makefile:4: recipe for target 'All' failed ====1 errors, 0 warnings====

我正在使用 CodeLite 9.0.9 和 SFML-2.3.2x86。

1。 “从 SFML 2.2 开始,当静态 linking 时,你将不得不 link SFML 对您的项目的所有依赖项也是如此。这意味着 例如,如果您正在 linking sfml-window-s 或 sfml-window-s-d,您 还得 link opengl32、winmm 和 gdi32。其中一些 依赖库可能已经列在“已继承 值”,但你自己再次添加它们不应该造成任何 问题。” 你的 linked 库应该有 -s 后缀,如果你是静态 linking 你应该 link 其他库看看 this.

2."When linking to multiple SFML libraries, make sure that you link them in the right order, it is very important for GCC. The rule is that libraries that depend on other libraries must be put first in the list. Every SFML library depends on sfml-system, and sfml-graphics also depends on sfml-window. So, the correct order for these three libraries would be: sfml-graphics, sfml-window, sfml-system -- as shown in the screen capture above." 设置link顺序为graphics-s/window-s/system-s/etc

3."It is important to link to the libraries that match the configuration: "sfml-xxx-d" 用于调试,"sfml-xxx" 用于发布。混音不好可能会导致崩溃。" 从你的构建日志中我可以看到你正在将你的项目构建为带有发布库的调试(那些没有 -d 后缀的),然后你必须将 linked 库更改为 sfml-graphics-s-d/etc

如果以上建议不起作用,则说明您设置的搜索路径有误。祝你好运

好的,所以我终于设法通过像这样更改库来修复它:-lsfml-graphics-s;-lsfml-window-s;-lsfml-audio-s;-lsfml-network-s;-lsfml-system-s;-lopengl32;-lfreetype;-ljpeg;-lwinmm;-lgdi32;-lopenal32;-lws2_32