Click here to Skip to main content
15,891,909 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello!
I want to write code on SFML on my computer, but it is with arch linux. I installed SFML. So now what editor could I use cause VIM gives an error for a basic "Hello world" code.

C++
#include <SFML/Graphics.hpp>
 
int main()
{
    sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");
 
    while (Window.isOpened())
    {
        sf::Event Event;
        while (Window.pollEvent(Event))
        {
            switch (Event.type)
            {
            case sf::Event::Closed:
                Window.close();
                break;
            default:
                break;
            }
        }
 
        Window.clear(sf::Color(0, 255, 255));
        Window.display();
    }
 
    return 0;
}


ERROR:
VB
testsfml.cpp: In function 'int main()':
testsfml.cpp:7:27: error: 'class sf::RenderWindow' has no member named 'isOpened'
             while (Window.isOpened())
                           ^
Posted
Comments
Radoslav Dimitrov 18-Sep-13 13:17pm    
Actually it is a simple application not Hello World
[no name] 18-Sep-13 13:21pm    
It's because, as clearly stated in the error message, RenderWindow does not have a isOpened member function. You might be interested in the isOpen member function though.
Radoslav Dimitrov 18-Sep-13 13:24pm    
tnx. But now it gives this huge error:


/tmp/ccHIAxjq.o: In function `main':
testsfml.cpp:(.text+0xeb): undefined reference to `sf::String::String(char const*, std::locale const&)'
testsfml.cpp:(.text+0x106): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
testsfml.cpp:(.text+0x12d): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
testsfml.cpp:(.text+0x161): undefined reference to `sf::Window::close()'
testsfml.cpp:(.text+0x178): undefined reference to `sf::Window::pollEvent(sf::Event&)'
testsfml.cpp:(.text+0x19d): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
testsfml.cpp:(.text+0x1b7): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
testsfml.cpp:(.text+0x1c6): undefined reference to `sf::Window::display()'
testsfml.cpp:(.text+0x1d5): undefined reference to `sf::Window::isOpen() const'
testsfml.cpp:(.text+0x1f1): undefined reference to `sf::RenderWindow::~RenderWindow()'
testsfml.cpp:(.text+0x238): undefined reference to `sf::RenderWindow::~RenderWindow()'
collect2: error: ld returned 1 exi
[no name] 18-Sep-13 13:33pm    
And? Did you include the header files that contain the definitions for those functions?
nv3 18-Sep-13 13:33pm    
Ok, the compiler has compiled your program. Now the linker is trying to find all those functions of the SMFL library and it looks like you didn't specify in the command line where it could find that library. See the tutorial and usage hints of SMFL to find out what you have to specify.

1 solution

The function's name that you want to call is not IsOpened but IsOpen.
 
Share this answer
 
Comments
Radoslav Dimitrov 18-Sep-13 13:25pm    
tnx to you too
nv3 18-Sep-13 13:29pm    
You are welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900