我正在尝试使用 CMake 将 SFML 链接到 C++ 项目。此设置在我的 Linux 机器上运行良好,但当我尝试在我的 Mac 上构建时,它找不到库:ld: library not found for -lsfml-network
。我对 SFML 的安装在两台机器上完全相同(按照我的安装方式)。
我的 CMakeLists.txt 链接如下所示:
target_link_libraries( Playground ${OpenCV_LIBS} sfml-network sfml-window sfml-graphics sfml-system )
最佳答案
SFML 在 how to compile using CMake 上有一个教程.它提供了一个 FindSFML.cmake
文件,因此您可以简单地使用 find_package
和 target_link_libraries
:
find_package(SFML REQUIRED COMPONENTS network window graphics system)
# ...
target_link_libraries(Playground
${SFML_LIBRARIES}
# If SFML did it correctly, this shouldn't be needed, but I can't tell from the
# documentation if they did:
${SFML_DEPENDENCIES}
)
关于c++ - 找不到 SFML 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49201207/