class sf::RenderWindow' has no member named 'clear'

c++, libraries, sfml

Solution

Not 100% sure, but since you're on Ubuntu it's very likely that instead of compiling SFML yourself, you just called `apt-get install sfml-dev` which in turn will install SFML 1.6 and not SFML 2.x. In SFML 1.6 the naming convention was CamelCase and was changed for SFML 2.0 to camelCase.

Since you want and should use SFML 2.x, you need to either use the unofficial package from the SFML forum or simply compile SFML yourself.

Problem

I've spent at least 5 hours trying to get the sfml library to work with my QT-creator ide. I have followed this tutorial https://github.com/LaurentGomila/SFML/wiki/Tutorial%3A-Compile-and-Link-SFML-with-Qt-Creator but still no luck. I continuously get the error that members of classes don't exist after building simple code. I can make instances of the classes, but I get multiple errors when trying to use members of the objects created. I have tried looking up library related issues, sfml issues, but I don't think I'm looking for the correct problem. This works and displays a window that will never close until forcing the program to quit: ``` #include <SFML/Graphics.hpp> int main() { sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!"); //sf::CircleShape shape(100.f ); //shape.setFillColor(sf::Color::Green); while (true)//window.isOpen()) { sf::Event event; /*while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); }*/ //window.clear(); //window.draw(shape); //window.display(); } return 0; } ``` As soon as I remove one comment an error pops up. I can't figure out for the life of me what's happening. Thanks in advance. Extra Info - Os: Ubuntu 12.10 Live (installed to hard drive) - Project File I'm sure this is incorrect ``` TEMPLATE = app #CONFIG += console CONFIG -= qt SOURCES += main.cpp LIBS += -L"/home/user/Projects/SFML/lib" CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-window -lsfml-system CONFIG(debug, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-window -lsfml-system INCLUDEPATH += "/home/user/Projects/SFML/include" DEPENDPATH += "/home/user/Projects/SFML/include" ``` - Errors: I'll post the compile output ``` main.cpp: In function 'int main()': main.cpp:6:5: error: 'CircleShape' is not a member of 'sf' main.cpp:6:21: error: expected ';' before 'shape' main.cpp:7:5: error: 'shape' was not declared in this scope main.cpp:12:23: error: 'class sf::RenderWindow' has no member named 'pollEvent' main.cpp:14:23: error: 'class sf::Event' has no member named 'type' main.cpp:15:24: error: 'class sf::RenderWindow' has no member named 'close' main.cpp:18:16: error: 'class sf::RenderWindow' has no member named 'clear' main.cpp:19:16: error: 'class sf::RenderWindow' has no member named 'draw' main.cpp:20:16: error: 'class sf::RenderWindow' has no member named 'display' 16:25:10: The process "/usr/bin/make" exited with code 2. Error while building project sfmlTest (target: Desktop) When executing build step 'Make' ``` - Executed Path ``` make: Leaving directory `/home/username/Documents/Projects/c++/Sfml/sfmlTest-build-desktop-Qt_4_8_1_in_PATH__System__Release' ``` - Compiler Used: I believe the Gnu Compiler, G ++

Original source