SFML community forums

Help => Window => Topic started by: RokB on December 03, 2012, 01:39:38 am

Title: Creating a window crashes program.
Post by: RokB on December 03, 2012, 01:39:38 am
Hello. I've been using SFML for a while now and I just upgraded to MinGW GCC 4.7.2. Now, whenever I try to create a window, my program crashes. I'm using SFML 2.0 and I already tried recompiling it and using the already compiled builds posted on the forum.

Creating a window crashes my progam:
int main(int argc, char* argv[])
{
        sf::Window window(sf::VideoMode(800, 600, 32), "test"); // crashes

        return 0;
}
 

But other things don't, so as far as I know it's just the window:
int main(int argc, char* argv[])
{
        sf::CircleShape circle;
        circle.setFillColor(sf::Color::Blue); // won't crash

        return 0;
}
 

Thanks in advance.
Title: Re: Creating a window crashes program.
Post by: Laurent on December 03, 2012, 08:06:14 am
What does the debugger say?

Are you sure that you recompiled SFML correctly, with the right version of MinGW?
Title: Re: Creating a window crashes program.
Post by: RokB on December 03, 2012, 10:35:35 pm
I tried recompiling it again. I'm pretty sure I'm using the correct version. This was in the debugger.

(http://i.imgur.com/rLEy1.png)

I also get a segmentation fault.
Title: Re: Creating a window crashes program.
Post by: eXpl0it3r on December 03, 2012, 11:41:50 pm
I tried recompiling it again. I'm pretty sure I'm using the correct version. This was in the debugger.
I also get a segmentation fault.
And you're 100% sure you're using the code posted in the first post?
Because the debugger seems to have the height of the window set to 32 and the BitsPerPixel to 2 which then results in a crash, since there's no video mode with 2 bits... ;)
So make sure you've that following code at window creation:
sf::Window window(sf::VideoMode(800, 600), "Hello World");
Title: Re: Creating a window crashes program.
Post by: RokB on December 03, 2012, 11:54:29 pm
I did actually notice that and I thought it was weird, but I am definitely using the correct code.

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

using std::cout;
using std::endl;

int main(int argc, char* argv[])
{
        sf::Window window(sf::VideoMode(800, 600), "Hello World");

        return 0;
}
 
Title: Re: Creating a window crashes program.
Post by: eXpl0it3r on December 04, 2012, 12:37:11 am
I did actually notice that and I thought it was weird, but I am definitely using the correct code.
Seriously, I've no idea what's going wrong, but it really seems like your setup is somewhere flawed, since I can build applications fine with MinGW GCC 4.7.2 (see my Nightly Builds (http://en.sfml-dev.org/forums/index.php?topic=9513.msg64716#msg64716) which include examples built with it).
Title: Re: Creating a window crashes program.
Post by: RokB on December 04, 2012, 01:32:46 am
Sorry. There must have been something wrong with my MinGW installation, even though I don't know exactly what. I downloaded your compiler and recompiled SFML and everything works now. Thanks.