Jump to content

  • Log In with Google      Sign In   
  • Create Account


SFML and Code::Blocks


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 mypel16000   Members   -  Reputation: 46

Like
0Likes
Like

Posted 05 January 2013 - 05:39 PM

Hi, I need to use SFML with Code::BLocks. I have used it loads of times in the past and it has allways worked. This time though, even after following every step on 10+ tutorials I cannot get it to work. The problem is that the program starts and it works fine, until it gets to the first SFML command. Then it stops working. I have read about the MinGW being outdated and I have installed the latest versions, but it still will not work.

 

I doubt anyone could give me some steps to solve this problem, but if they could give me the CodeBlocks files with SFML already installed that would be great!



Sponsor:

#2 CJ_COIMBRA   Crossbones+   -  Reputation: 780

Like
1Likes
Like

Posted 05 January 2013 - 07:58 PM

It stops working, but what kind of error do you get? Try putting some breakpoints and follow the execution step by step, also it would help us helping you by providing the piece of code you're trying to run. Perhaps it's not related to Code::Blocks at all.



#3 mypel16000   Members   -  Reputation: 46

Like
-2Likes
Like

Posted 06 January 2013 - 04:14 AM

I don't get an error. I don't get it when I run it and I don't get it when I debug. This must mean that all the libraries work properly. The problem is that I start running my code:

 

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

using namespace std;


int main()
{
    cout<< "Main Working"
    bool Running = true;
    while (Running)
    {
        cout << "Loop Working";
        sf::Window App(sf::VideoMode(800, 600, 32),"Hello");
        App.Display();
        cout << "Screen Working"
    }
}

 

As you can see I am just trying to simply open up a window. What I get is:

 

Main Working Loop Working

 

Then the program "blablabla.exe stopped responding" Just like other programs often crash. Only that it allways happen. At this stage i'm sure it probably isn't an error of the code.



#4 wintertime   Members   -  Reputation: 1640

Like
0Likes
Like

Posted 06 January 2013 - 04:50 AM

I dont know much about SFML but you seem to just loop endlessly over the initialization part and never start working on the generated messages, no wonder Windows complains about that.



#5 stitchs   Crossbones+   -  Reputation: 1281

Like
2Likes
Like

Posted 06 January 2013 - 06:35 AM

I see two issues with the code you have posted:

 

The first being there are two semi-colon's missing after 2 of your 3 cout's (the first and the third, as underlined below):

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

using namespace std;


int main()
{
    cout<< "Main Working"
    bool Running = true;
    while (Running)
    {
        cout << "Loop Working";
        sf::Window App(sf::VideoMode(800, 600, 32),"Hello");
        App.Display();
        cout << "Screen Working"
    }
}

 

This causes your program to think that a certain line ends in a place different to where you want it to, which can lead to undesired effects (although, why your compiler isn't throwing up some sort of error puzzles me).

 

Secondly: sf::Window should only need to be created once, outside the (while) loop. When I tried the same as your code, in my IDE, I had a window being created and destroyed over and over, whilst the loop ran. This lead to an effect by which a window would open and close every couple of seconds (maybe this is something your compiler doesn't like and crashes the program for you, I'm not sure, please correct me if I am wrong).

 

Try it with these and get back to us, if anything, it might not fix the problem, but allow a new (debugger tracked one) to be picked up.

 

Regards,

 

Stitchs.



#6 mypel16000   Members   -  Reputation: 46

Like
-3Likes
Like

Posted 06 January 2013 - 09:57 AM

You just don't realize it..... It's not about the code. I wrote that in 2 secs on game dev. I didn't copy it directly! I have fixed it already and it's an issue with the latest version of CodeBlocks.



#7 stitchs   Crossbones+   -  Reputation: 1281

Like
2Likes
Like

Posted 06 January 2013 - 10:53 AM

No offense to you but, when you say:

 

The problem is that I start running my code: (insert code here)

 

You're kind of giving people misleading information as to how they can solve your problem. If you had posted a direct copy-paste of your code, myself, as well as other forum members, wouldn't need to waste time reading/responding to inaccurate data. We could get to the problem at hand. Now I realise a counter-argument might be that you said in your first post you're sure it's the fault of an outdated MinGW but, to follow up with what you provided might suggest to some that you are at a level of experience lower than you know you are.

 

So that the community could give more possible responses, could you tell us the versions of MinGW and SFML that you're using, have you tried to google information that includes these version numbers as your searches might be too general.

 

Regards,

 

Stitchs.



#8 Chad Smith   Members   -  Reputation: 1078

Like
1Likes
Like

Posted 06 January 2013 - 03:39 PM

I would copy and paste the direct contents of your code.  While it may not seem like your code has a problem it is very likely it can be.  It happens all the time to programmers.  We just know our code is right that nothing is wrong with it.  Then we show it to someone else and they see it within 10 seconds.  It can happen all the time in anything, not just programming.  It's one of those things that happens when you look at something for too long.  Sometimes you need a fresh set of eyes.

 

The chances of this being a Code::Blocks issue is very slim.  If it compiles and links just fine and starts up then I don't see it being a Code::Blocks issue.  I guess it is possible it could be something to do with the SFML files though first I'd want to see your code.

 

Next would be the project settings.  I can assume it could be a possibility that your project settings aren't exactly right, though with just a basic SFML app I would think if you have it linked properly and it compiles fine then that would be fine too.

 

Seriously just copy and paste your code and we will do everything we can to try to help.  We all make mistakes and we sometimes need fresh set of eyes to see the problem.  If you have by chance fixed the issue then post your solution here.  That way someone else who could be having the same problem could see and it could help someone else.

 

Without any of this information it's going to be nearly impossible to try to help you.  That code you posted above, even though you said it was not a direct copy and paste (not sure why you wouldn't though), we immediately saw something.


Edited by Chad Smith, 06 January 2013 - 03:42 PM.


#9 stitchs   Crossbones+   -  Reputation: 1281

Like
0Likes
Like

Posted 19 January 2013 - 01:41 PM

Can I ask as to why my response has been down-voted 2 weeks after this topic was last updated?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS