我已经在学校项目的debian上安装了SFML1.6。
编译时我有错误:
g ++ -c main.cpp
g ++ main.o -o bomberman -lsfml-graphics
/usr/local/lib/libsfml-graphics.so:
sf::Unicode::Text::Text()' /usr/local/lib/libsfml-graphics.so: undefined reference to
sf的未定义引用:: Context :: GetGlobal()' /usr/local/lib/libsfml-graphics.so:对sf::Window::OnEvent(sf::Event const&)' /usr/local/lib/libsfml-graphics.so: undefined reference to
sf :: Window :: Create的未定义引用(sf :: VideoMode,std :: basic_string,std :: allocator> const&,unsigned long ,sf :: WindowSettings const&)' /usr/local/lib/libsfml-graphics.so:sf :: Window'的sf::Context::SetActive(bool)' /usr/local/lib/libsfml-graphics.so: undefined reference to
typeinfo的未定义引用 /usr/local/lib/libsfml-graphics.so:对sf::Window::Create(unsigned long, sf::WindowSettings const&)' /usr/local/lib/libsfml-graphics.so: undefined reference to
sf :: Window :: GetHeight()const'的未定义引用 /usr/local/lib/libsfml-graphics.so:对sf::Window::Window()' /usr/local/lib/libsfml-graphics.so: undefined reference to
sf的未定义引用:: Unicode :: Text :: Text(unsigned int const *)' /usr/local/lib/libsfml-graphics.so:sf::Window::~Window()' /usr/local/lib/libsfml-graphics.so: undefined reference to
sf :: Context :: IsContextActive()'的未定义引用 /usr/local/lib/libsfml-graphics.so:sf::Window::SetActive(bool) const' /usr/local/lib/libsfml-graphics.so: undefined reference to
sf :: Unicode :: Text :: operator std :: basic_string,std :: allocator>的未定义引用const&()const' /usr/local/lib/libsfml-graphics.so:对`sf :: Window :: GetWidth()const'的未定义引用 collect2:ld返回1退出状态 make: * [all]错误1
我不明白为什么会出现这些错误。 libsfml- *位于/ usr / lib /中,所有需要包含在/ usr / include
中答案 0 :(得分:1)
您还必须链接到sfml的窗口和系统库。
g++ main.o -o bomberman -lsfml-graphics -lsfml-window -lsfml-system
您还应该阅读this tutorial