我正在尝试在我的项目中包含SFML源代码。我的目录布局如下:
main
SFML (subtree synced with the official git repo)
src
<various modules>
General (here lies the binary)
从主要级别我首先添加SFML子目录然后再添加src。正如我看到构建日志,这会生成库:
sfml‑system
sfml‑window
sfml‑network
sfml‑graphics
sfml‑audio
sfml‑main
现在我想将它们链接到General目录中的二进制文件,如下所示:
add_executable(main ${main_SRCS})
target_link_libraries (main
sfml‑system
sfml‑window
sfml‑network
sfml‑graphics
sfml‑audio
sfml‑main
# Other stuff here
)
但我明白了:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsfml‑system
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsfml‑window
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsfml‑network
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsfml‑graphics
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsfml‑audio
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsfml‑main
为什么CMake尝试使用系统库而不是刚刚构建的系统库以及如何解决这个问题?