我想在我的项目中包含SFML源代码。我的目录是这样布局的:来自子目录的CMake链接库
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
现在,我想他们在总目录这样的链接到我的二进制:
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尝试使用系统库而不是刚刚构建的系统库,以及如何解决这个问题?
那些库是同一个CMake项目的目标吗?如果是这样,是'sfml-system'等目标的实际名称? –
顶级CMakeLists作用: 'add_subdirectory(SFML) add_subdirectory(SRC)' 我可以看到生成日志库名称: 'CXX链接共享库../../../lib/ libsfml-graphics.so等 – Tommalla
@BaummitAugen我刚刚意识到SFML子目录定义了自己的项目。我想这会回答你的问题,并以某种方式改变我的东西? – Tommalla