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

Author Topic: unknown project crash?  (Read 2870 times)

0 Members and 5 Guests are viewing this topic.

KruSuPhy

  • Newbie
  • *
  • Posts: 7
    • View Profile
unknown project crash?
« on: August 13, 2013, 10:20:57 am »
This keeps crashing for some reason, and I can't figure out why. I keep getting the "so-and-so.exe has stopped working" error.
        int maxTilesX = 24;
        int maxTilesY = 12;
        sf::RenderWindow window(sf::VideoMode(maxTilesX * 32, maxTilesY * 32), "Game");

        while (window.isOpen())
        {
            sf::Event event;

            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                {
                    window.close();
                }
            }

            sf::Font font;
            sf::Text text;
            if (!font.loadFromFile("arial.ttf"))
            {

            }

            text.setFont(font);
            text.setCharacterSize(24);
            text.setColor(sf::Color::Black);
            text.setString("Hello World!");

            window.clear(sf::Color::White);
            window.draw(text);
            window.display();


        }

        return 0;

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: unknown project crash?
« Reply #1 on: August 13, 2013, 10:55:11 am »
Chances are that you're using the wrong version for your compiler.
What compiler + OS are you using and which SFML package did you download?

Btw. don't load the font in the main loop, otherwise it will try to load the font every loop iteration, like 2000 times a second. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

KruSuPhy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unknown project crash?
« Reply #2 on: August 13, 2013, 11:11:30 am »
GNU GCC Compiler(C::B Default), Windows 8, and SFML 2.1. The thing is, it was working fine earlier. There's some sort of problem with window.clear(); because I commented it out and the program worked. It's got some problem with the clear, i guess.

And thanks for the tip about the font!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: unknown project crash?
« Reply #3 on: August 13, 2013, 11:24:36 am »
Well you left out what SFML 2.1 package you got. What exactly did you download?

Shouldn't have anything to do with the clear. It's just that with inconsistent compiler versions, you can get pretty odd things happening.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

KruSuPhy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unknown project crash?
« Reply #4 on: August 13, 2013, 11:14:48 pm »
I downloaded GCC 4.7 MinGW (DW2) - 32 bits.

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: unknown project crash?
« Reply #5 on: August 13, 2013, 11:28:53 pm »
There are multiple variants of gcc for Windows, which are incompatible with each other (different exception management, threading model, etc.). Make sure that you pick up the right package according to the version that you use. If you don't know, check which of the libgcc_s_sjlj-1.dll or libgcc_s_dw2-1.dll file you have in your MinGW/bin folder. If you're using the version of MinGW shipped with Code::Blocks, you probably have a SJLJ version.
This?  ??? ??? ???

I'm not sure, because you said it was working earlier.
« Last Edit: August 13, 2013, 11:31:10 pm by G. »

KruSuPhy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unknown project crash?
« Reply #6 on: August 15, 2013, 04:23:08 am »
no, i've got the libgcc_s_dw2-1.dll in my MinGW/bin.

i dunno. i had another project that i was following the tutorial on and it was working fine. i just decided to start a new one to see if i could remember how to do it all. and i checked my code and stuff, it looked right to me. so i'm not sure why it just randomly doesn't want to work.

EDIT: Okay, so i'm able to recreate the error. I erased all of my files in the same project and wrote this:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800,600), "Window");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.display();
    }

    return 0;
}

and this works fine. i mean, it's just a blank window, but it works fine.

However, when I changed it to sf::RenderWindow and added window.clear();, as such:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800,600), "Window");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.display();
    }

    return 0;
}
the same "blah blah has stopped working" error happens. I don't know if that helps at all, honestly, but I figured i'd try something and it ended up just giving me the same error.
« Last Edit: August 15, 2013, 05:26:07 am by KruSuPhy »

KruSuPhy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unknown project crash?
« Reply #7 on: August 24, 2013, 06:19:15 am »
bumpppp. still having the same problem. any ideas?  :-\

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
AW: unknown project crash?
« Reply #8 on: August 24, 2013, 10:30:41 am »
Well it was already pointed out. You use the wrong SFML version for your compiler. It's written in red in the tutorial... ::)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

KruSuPhy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unknown project crash?
« Reply #9 on: August 24, 2013, 06:11:03 pm »
but i'm supposed to use the version that matches the file that I have in my MinGW/bin folder, right? I don't have the SLJL file in there, it's the libgcc_s_dw2-1.dll. Should I download the SLJL version anyway?

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: unknown project crash?
« Reply #10 on: August 24, 2013, 06:56:19 pm »
I've quoted the tutorial, but I don't really know what's supposed to happen when you use the wrong binaries (cause I've never tried), and since eXpl0it3r agrees and noone else has emitted another idea...
Maybe it's worth spending 5 minutes (download included) to try it instead of being stuck for almost 2 weeks. Nop?
You have the DW2 dll, but maybe you also have the SJLJL one?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: unknown project crash?
« Reply #11 on: August 24, 2013, 06:58:01 pm »
The default compiler of Code::Blocks is the TDM version, which uses SJLJ for exceptions, thus you'll have to download the SJLJ version from SFML's download page.

Why the TDM compiler ships the DW2 version of the stdlib as well, is unknown to me.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

KruSuPhy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unknown project crash?
« Reply #12 on: August 24, 2013, 10:05:24 pm »
I mean, yeah, I'll try it. It just doesn't make any since because I didn't have any problems on my other project.