c++ - 找不到 SFML 库

标签 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 )

最佳答案

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

关于c++ - 找不到 SFML 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49201207/

相关文章:

c++ - 不同的 clang 和 gcc 行为与指针

c++ - 即使主窗口关闭,应用程序也不会退出

c++ - CMake 生成的 Xcode 项目无法找到从 Xcode 构建的二进制 "Products"

c++ - 如何在 cmake >= 2.6 中使用没有 gnu 扩展的 c++98?

iphone - 我如何从 iOS 框架中删除或重命名符号?

c++ - 无法从 'const Eigen::GeneralProduct<Lhs,Rhs,ProductType>' 转换为 'double'

c++ - CMake TARGET_LINK_LIBRARIES 中包含多个静态库

swift - 现在删除了 firebase 我得到 Linker command failed with exit code 1

c++ - undefined reference (SFML)

c++ - 编译器优化打破了惰性迭代器