我是C++的新手并且尝试学习游戏编程,我选择SFML并使用Jetbrain在CLion上运行并使用Ubuntu机器.我在这里学习SFML和Linux这个教程 我的代码:
#includeusing namespace sf; int main() { RenderWindow window(sf::VideoMode(200, 200), "SFML Work!"); CircleShape shape(100.f); shape.setFillColor(Color::Green); while (window.isOpen()) { Event event; while (window.pollEvent(event)) { if (event.type == Event::Closed) { window.close(); } } window.clear(); window.draw(shape); window.display(); } return 0; }
当我在CLion上运行时出错了
CMakeFiles/SFMLBasic.dir/main.cpp.o: In function `main': undefined reference to `sf::String::String(char const*, std::locale const&)' undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)' undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)' ... undefined reference to `sf::Shape::~Shape()'
我如何配置或设置在CLion中运行SFML,我不知道CMAKE可以做到这一点?我只运行终端,如果运行此命令,它会工作.
g++ -c main.cpp g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system ./sfml-app
如何配置使用所有引用变量而不是每次都在终端手动?谢谢.