找不到 SFML 库

SFML libraries not found

我正在尝试使用 CMake link SFML 到 C++ 项目。此设置在我的 Linux machine 上运行良好,但当我尝试在我的 mac 上构建时,它找不到库:ld: library not found for -lsfml-network。我对 SFML 的安装在两个 machines 上完全相同(以我的方式)。

我的 CMakeLists.txt linking 看起来如下:

target_link_libraries( Playground ${OpenCV_LIBS} sfml-network sfml-window sfml-graphics sfml-system )

SFML 在 how to compile using CMake 上有一个教程。它提供了一个 FindSFML.cmake 文件,所以你可以简单地使用 find_packagetarget_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}
)