【问题标题】:Linking SFML in CodeLite在 CodeLite 中链接 SFML
【发布时间】:2016-05-08 10:50:56
【问题描述】:

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

  1. 将 SFML 的 include 文件夹添加到 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。

【问题讨论】:

    标签: c++ compiler-errors g++ sfml codelite


    【解决方案1】:

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

    2.“在链接多个SFML库时,请确保以正确的顺序链接它们,这对GCC非常重要。规则是依赖于其他库的库必须是排在第一位。每个 SFML 库都依赖于 sfml-system,而 sfml-graphics 也依赖于 sfml-window。因此,这三个库的正确顺序是:sfml-graphics、sfml-window、sfml-system - - 如上面的屏幕截图所示。” 将链接顺序设置为 graphics-s/window-s/system-s/etc

    3.“链接到与配置匹配的库很重要:“sfml-xxx-d”用于调试,“sfml-xxx”用于发布。可能会导致错误的混合在崩溃中。” 从您的构建日志中,我可以看到您正在将项目构建为使用发布库(没有 -d 后缀的那些)进行调试,那么您必须将链接库更改为 sfml-graphics-sd/etc

    如果上述建议不起作用,那么您设置的搜索路径错误。祝你好运

    【讨论】:

    • 好的,我将链接库更改为:sfml-graphics-s;sfml-window-s;sfml-audio-s;sfml-network-s;sfml-system-s;glew;opengl32 ;freetype;jpeg;winmm;gdi32;sndfile;openal32;ws2_32;
      我现在正在将项目构建为 Release,但它仍然说它找不到任何这些库的文件
    • 尝试将 sfml 库链接为 libsfml-graphics-s;libsfml-window-s;等等。为它们添加 lib 前缀(仅适用于 sfml 库,而不适用于 opengl/etc)
    • 添加 .lib 怎么样?例如 sfml-graphics-s.lib
    • 还是什么都没有。但我不认为问题出在这个,因为为什么它甚至无法找到opengl32
    • 它确实对我有用。我的链接器选项 libs 和 codelite 忽略 sfml_static 预处理器,所以在代码中你必须 #define SFML_STATIC :) look
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2016-06-26
      • 2018-12-22
      • 1970-01-01
      • 1970-01-01
      • 2018-09-24
      • 1970-01-01
      • 1970-01-01
      • 2015-05-16
      • 2016-11-19
      相关资源
      最近更新 更多