Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Code::Blocks and C++ has stopped working.  (Read 6687 times)

0 Members and 1 Guest are viewing this topic.

Airspace

  • Newbie
  • *
  • Posts: 3
    • View Profile
[Solved] Code::Blocks and C++ has stopped working.
« on: August 12, 2013, 03:40:32 am »
I have tried to follow the tutorial to get SFML setup under Code::Blocks and when I try to compile and run the program using the code provided in the tutorial windows simply comes up with the executable has stopped working. I have redone the tutorial several times and I have made sure to download the correct version of SFML and it still will not run.

EDIT:

Also I have run the debugger and it keeps telling me that it is a segmentation fault.
« Last Edit: August 12, 2013, 05:57:17 am by Airspace »

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Re: Code::Blocks and C++ has stopped working.
« Reply #1 on: August 12, 2013, 03:49:58 am »
If it's a segmentation fault, then you're using pointers. Incorrectly, I might add. Please, post complete and minimal source code that demonstrates the issue so we can point out exactly what is wrong.
I use the latest build of SFML2

Airspace

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Code::Blocks and C++ has stopped working.
« Reply #2 on: August 12, 2013, 03:53:53 am »
Code: [Select]
#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 (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;
}

I got the code directly from the tutorial provided on the SFML site.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Re: Code::Blocks and C++ has stopped working.
« Reply #3 on: August 12, 2013, 04:02:14 am »
That exact code works perfectly fine on my computer, drawing a green circle that covers the window as expected. Try recompiling SFML or reinstalling it, it may be a bad configuration. Also, make sure you're on the latest version.
« Last Edit: August 12, 2013, 04:13:11 am by OniLinkPlus »
I use the latest build of SFML2

Airspace

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Code::Blocks and C++ has stopped working.
« Reply #4 on: August 12, 2013, 05:47:20 am »
I actually think that it was that I had not updated my Code::Blocks for quite some time and that it wasn't compatible with the version that I had. After I updated Code::Blocks it all worked fine.

Thank you for all your help.