I am new to C ++ and try to learn game programming, I choose SFML and run on CLion using Jetbrain and using the Ubuntu machine. I follow this SFML and Linux tutorial here my code is:
#include <SFML/Graphics.hpp> using 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; }
When I run CLion, this is an error
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()'
How do I configure or configure SFML to run in CLion, I donβt know that CMAKE can do this? I only run the terminal, It works if I run this command.
g++ -c main.cpp g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system ./sfml-app
How to configure to use the entire reference variable without manual input to the terminal each time? Thanks.
source share