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

Author Topic: Creating a window crashes program.  (Read 4898 times)

0 Members and 1 Guest are viewing this topic.

RokB

  • Newbie
  • *
  • Posts: 8
    • View Profile
Creating a window crashes program.
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Creating a window crashes program.
« Reply #1 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?
Laurent Gomila - SFML developer

RokB

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Creating a window crashes program.
« Reply #2 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.



I also get a segmentation fault.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Creating a window crashes program.
« Reply #3 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");
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

RokB

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Creating a window crashes program.
« Reply #4 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;
}
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Creating a window crashes program.
« Reply #5 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 which include examples built with it).
« Last Edit: December 04, 2012, 12:38:55 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

RokB

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Creating a window crashes program.
« Reply #6 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.