CMake + SFML链接器错误,即使在CMakeLists.txt中指定了库

时间:2017-10-23 17:30:32

标签: c++ cmake sfml

我正在使用SFML和CMake制作一个项目。为此,我跟着the guide from SFML's GitHub 我将以下行添加到我的CMakeLists.txt:

Found SFML 2.4.2 in F:/Dev/CPPLibs/SFML-2.4.2/include

这些行大多只是从我提到的指南中复制而来。在ArchLinux上,从存储库安装SFML后,这非常有效,生成的MakeFile生成可执行文件

在Windows上,在将SFML_ROOT环境变量设置为我的SFML位置后,CMake成功运行,找到SFML并生成以下输出:

...
C:\Users\complover116\Documents\CVMControl\src\cl_game.cc:14: error: undefined reference to `_imp___ZN2sf12RenderTarget7setViewERKNS_4ViewE'
C:\Users\complover116\Documents\CVMControl\src\cl_game.cc:15: error: undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
C:\Users\complover116\Documents\CVMControl\src\cl_game.cc:15: error: undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
... etc

但是,尝试使用生成的MakeFile进行构建会导致链接器错误:

message(${SFML_LIBRARIES})

另外,将调试命令添加到CMakeLists.txt

debugF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-network-d.aoptimizedF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-network.adebugF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-audio-d.aoptimizedF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-audio.adebugF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-graphics-d.aoptimizedF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-graphics.adebugF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-window-d.aoptimizedF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-window.adebugF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-system-d.aoptimizedF:/Dev/CPPLibs/SFML-2.4.2/lib/libsfml-system.a

输出:

forEach

它像这样连接,我没有错误地复制

我做错了什么?

0 个答案:

没有答案