SFML community forums

Help => General => Topic started by: Sightburner on June 09, 2015, 09:50:57 pm

Title: SFML Blueprint build problems in C::B
Post by: Sightburner on June 09, 2015, 09:50:57 pm
I bought the book "SFML Blueprint" today and in the book the reader was tasked with compiling SFML 2.2 with CMAKE and to compile the basic "make a circle appear" test program. The code compiles but when the application starts it dies with a "X.exe has stopped working. Windows is looking for a solution" dialog popping up.

CMAKE window
(http://i.imgur.com/OInCiwr.png)
and the files it gave me
(http://i.imgur.com/JkIoyaN.png)

I followed the steps and compiled SFML and opened C::B, and followed the steps the book said me to follow.
(http://i.imgur.com/m6gZtfj.png)
(http://i.imgur.com/rrDO7G5.png)
(http://i.imgur.com/Nz8pCLm.png)

The code example used is from the book and looks like this:
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main(int argc,char* argv[])
{
    //the window use for the display
    sf::RenderWindow window(sf::VideoMode(400,400),"01_Introduction");
    //set the maximum frame per second
    window.setFramerateLimit(60);

    //construct a circle
    sf::CircleShape circle(150);
    //set his color
    circle.setFillColor(sf::Color::Blue);
    //set his position
    circle.setPosition(10, 20);

    //main loop
    while (window.isOpen())
    {
        //to store the events
        sf::Event event;
        //process events
        while(window.pollEvent(event))
        {
            //Close window
            if (event.type == sf::Event::Closed)
                window.close();
            //keyboard input : Escape is press
            else if (event.type == sf::Event::KeyPressed and event.key.code == sf::Keyboard::Escape)
                window.close();
        }

        //Clear screen
        window.clear();

        //draw the cirle
        window.draw(circle);

        //Update the window
        window.display();

    }

    return 0;
}
 
Anyone has any clue what I might have done wrong? My guess is that I made some error during the CMAKE process, but I have never used CMAKE before so I have no clue what I can try.
Title: Re: SFML Blueprint build problems in C::B
Post by: SpeCter on June 09, 2015, 10:24:47 pm
Did you put the .dll files next to your executable?
Title: Re: SFML Blueprint build problems in C::B
Post by: Sightburner on June 09, 2015, 10:35:25 pm
Yes, if I didn't I would get another error that say x.dll is missing.
Title: Re: SFML Blueprint build problems in C::B
Post by: eXpl0it3r on June 09, 2015, 10:46:56 pm
Have you built the example in debug mode, while linking the release libraries?
Is your GPU driver uptodate?

At best you build the debug version of SFML and create a debug version of the example, then run it through GDB and find out where it crashes exactly.
Title: Re: SFML Blueprint build problems in C::B
Post by: Sightburner on June 09, 2015, 10:54:53 pm
I added output after each line in the code, and it crashed here:
Code: [Select]
sf::RenderWindow window(sf::VideoMode(400,400),"01_Introduction");I have no clue how to build a debug version with the CMAKE, or is that done in the C::B project CMAKE creates for me? I have tried the dll-files in release, and debug. I have my graphics driver up to date.

*EDIT*
I guess I change "Release" in CMAKE to "Debug" so I'll try that.

*EDIT 2*
I guess I built the debug correctly, but I still have the same problem that it crashes on the same line as before.
Title: Re: SFML Blueprint build problems in C::B
Post by: Mario on June 10, 2015, 10:29:23 am
Have you tried just debugging in C::B? Set a break point at the start of your main() and then run step by step, if it notices a crash, you should be able to review the values of variables etc. to find out more.
Title: Re: SFML Blueprint build problems in C::B
Post by: Sightburner on June 10, 2015, 01:22:46 pm
This is the result from the debug with a breakpoint
(https://i.imgur.com/0Dh56B8.png)
Title: Re: SFML Blueprint build problems in C::B
Post by: eXpl0it3r on June 10, 2015, 01:32:34 pm
If it crashes because of strings it's most likely an incompatibility between the runtime libs.
Has SFML been built with the exact same compiler as you're building your application with?
Title: Re: SFML Blueprint build problems in C::B
Post by: Sightburner on June 10, 2015, 01:59:24 pm
Yes, both are built in C::B 10.05.
And I use the source for SFML 2.2 to build all the SFML stuff.
Title: AW: SFML Blueprint build problems in C::B
Post by: eXpl0it3r on June 10, 2015, 04:44:35 pm
Any reason for using an outdated Code::Blocks version?
Title: Re: SFML Blueprint build problems in C::B
Post by: Sightburner on June 10, 2015, 10:17:25 pm
No, I had forgot to update it on my second machine.
I updated to 13.12 and re-compiled SFML and the test project.

One problem I see now is that d:/program/codeblocks doesn't exist. I reinstalled C::B on C:\ but for some reason it is still looking on D:\ I cannot figure out what to try. I did reboot the computer after the installation just in case but the problem is persisting.

(http://i.imgur.com/9YeRiLJ.png)
Title: Re: SFML Blueprint build problems in C::B
Post by: Hapax on June 10, 2015, 10:30:45 pm
the test project.
[screenshot]
Is this in debug mode? I ask because "\bin\Release\sfml-system-2.dll" suggests otherwise.
Title: Re: SFML Blueprint build problems in C::B
Post by: Sightburner on June 10, 2015, 10:39:56 pm
The image is updated, I rebuilt again when I noticed that, and got a new error.
This seem to be C::B related though.