未定义对(SFML)的引用 [英] Undefined reference to (SFML)
本文介绍了未定义对(SFML)的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将SFML与CMake链接,但是make存在一些问题:
I am trying to link SFML with CMake, but I have some issues with make:
/home/ishidex2/Documents/QtCreator/CMakeExample/main.cpp:-1: error: undefined reference to `sf::String::String(char const*, std::locale const&)'
还有诸如此类的错误.
首先,我通过以下命令安装了SFML:
First of all, I installed SFML by this command:
sudo apt-get install libsfml-dev
然后按照本教程进行操作:
And then followed this tutorial :
https://github.com/SFML/SFML/wiki/Tutorial:-Build-your-SFML-project-with-CMake
我认为链接存在问题,但我不知道如何解决.
I think this is a problem with linking, but I don't know how to fix it.
我的链接顺序是:
find_package(SFML 2 REQUIRED graphics window main system)
推荐答案
find_package
不执行任何链接,您需要使用 target_link_libraries
,如您所看到的链接所示发表自己:
find_package
does not perform any linking, you need to use target_link_libraries
as seen in the link that you posted yourself:
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
这篇关于未定义对(SFML)的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文