找不到SFML库

时间:2018-03-09 19:53:05

标签: c++ cmake linker-errors

我正在尝试使用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 )

1 个答案:

答案 0 :(得分:1)

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}
)