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

Author Topic: [Solved] Crashing within sf::RenderWindow constructor.  (Read 1682 times)

0 Members and 1 Guest are viewing this topic.

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
[Solved] Crashing within sf::RenderWindow constructor.
« on: May 03, 2013, 11:36:56 pm »
I just downloaded the latest SFML 2, and now I have mysterious crashes when going over the sf::RenderWindow constructor.  With this makefile and code, "test 1" is displayed, then the program crashes.  I am not very familiar with static linking, so that could be the cause.  Any help would be greatly appreciated.

compile = -c -Wall -std=c++0x -g # -mwindows
link = -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -g  # -mwindows -lsfml-main
objects = sfmlTesting.o

all: $(objects)
        g++ $(objects) $(link) -o sfmlTesting.exe

sfmlTesting.o: sfmlTesting.cpp
        g++ sfmlTesting.cpp $(compile)

check-syntax:
        g++ -Wall -o nul -std=c++0x -S ${CHK_SOURCES}
 

#define SFML_STATIC

#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    std::cout << "test 1" << std::endl;
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    std::cout << "test 2" << std::endl;
    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;
}
 
« Last Edit: May 05, 2013, 05:27:01 am by blueeyedlion »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Crashing within sf::RenderWindow constructor.
« Reply #1 on: May 04, 2013, 08:09:22 am »
Make sure that the SFML package that you downloaded matches your compiler perfectly. If it matches, then try to remove the -std=c++0x flag.

By the way, SFML_STATIC should not be defined in source code, but rather in your compile flags (-DSFML_STATIC).
Laurent Gomila - SFML developer

blueeyedlion

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Re: Crashing within sf::RenderWindow constructor.
« Reply #2 on: May 04, 2013, 11:59:08 pm »
Updating the compiler fixed everything.  Thanks.