C++ program using SDL freezes after being moved to a new computer

Uh yeah. So basically, I've been working on a game for a while to learn about C++, and I kinda went overboard with the project and made it into something I work on quite a lot. Anyway, I had to migrate my project from one computer to another, and for some reason it freezes fairly easily and somewhat unpredictably.

The program compiles fine and on the computer it previously ran on, worked fine without a hitch. However, on this computer (I don't have access to the old computer), it still compiles properly but freezes very quickly. I put a cout << "End of frame!" << endl; at the end of the program loop, and it seems that the game will usually get through one frame and then stop. However, it occasionally gets through several seconds while accepting user input until it stops working. Then it freezes again.

I honestly haven't any idea what the issue is... I wish I had more information concerning the issue, but I really don't know what steps to take to fix it. I suspect it may be a problem with C::B (the compiler I'm using) or a peculiarity with my code that makes it fail on my computer. I'm unsure what code to include if any, seeing how it worked fine on a different machine.

I'm running Ubuntu 12.04.4 and the computer it worked on was running Lubuntu something-or-another. I'm on a fairly old machine but I feel like I did my best to make my code system-independent.

Anyway, I'm kinda new to forums (my first post, haha) so I apologize greatly if I didn't include enough information or seem uninformed about the question I'm asking. Hopefully I did a good job asking and the problem can be resolved easily enough. Thanks for all the help I hope I can get.

(Oh and of course I did try some simple searching around on Google and stuff to make sure nobody else had a nearly identical issue.)

Anyway, if I need to include more info, just ask! Hopefully that won't be necessary though and I've included enough.
http://www.cplusplus.com/forum/general/112111/

http://hwrnmnbsol.livejournal.com/148664.html
http://blog.codinghorror.com/rubber-duck-problem-solving/


> I put a cout << "End of frame!" << endl; at the end of the program loop
I recommend you to use a debugger. You may set a breakpoint or interrupt the program, then you can take a look at where you are (and how you've got there) and the values of the variables.

> I suspect it may be a problem with C::B (the compiler I'm using)
C::B is not a compiler, but an IDE. gcc is a compiler.
However, if you blame on it, ¿then what can you do to fix your problem?

> I'm unsure what code to include
enough to reproduce your issue.
given that you say that the program worked fine in another machine, and that the fail is unpredictably, even posting all may be too little. However, we need something to work on.
I recommend you to use a debugger. You may set a breakpoint or interrupt the program, then you can take a look at where you are (and how you've got there) and the values of the variables.

After digging around for quite a while, I've managed to realize that I have no idea even in the slightest how to use debugging tools, and it seems that all the tutorials I'm finding are assuming that I know lots of things that I don't... This is a nooby question of it's own, but how do I get started understanding how to use breakpoints and step into and stuff like that?

C::B is not a compiler, but an IDE. gcc is a compiler.
However, if you blame on it, ¿then what can you do to fix your problem?

Oh yes, I didn't realize that I had said "compiler" instead of "IDE". Thanks for pointing that out, haha. I'm using GCC, yes.

enough to reproduce your issue.

Uh well, as it happens I'm not exactly a very good coder and most of my code is so highly interdependent upon itself that I can't easily seperate one part from another. So, including only part of it might prove unfeasible...

A few more things I should add before I forget to write them down:
1) No user input is required in order to produce different output. This is just outright weird and I really don't think this is how programs are supposed to work.
2) As mentioned above, I don't know how to use a debugger and honestly don't know where to start. I know it's a really super nooby question, and is likely somewhat irritating to all you guys (being used to super complex and in-depth questions as I'm sure you are, haha), but either I'm really really bad at Google or I'm doing something terribly wrong, because I honestly can't figure out how to do this.
3) I know it might seem like I haven't put much effort into solving this for myself, but honestly, I really have and I'm just SO much of a noob to this that I just can't quite work out how to do it. So if I feel like a frustrating question-asker, I totally apologize for that. Hopefully you guys can understand.
Last edited on
http://sunsite.ualberta.ca/Documentation/Gnu/gdb-4.18/html_chapter/gdb_toc.html
your IDE may facilitate a lot of those operations.
read what you are interested in, by instance 5.1 talks about breakpoints, and 5.2 about stepping.

In order to set a breakpoint in a particular line of code, that place should be interesting. You may want to know how did you reach it (backtrace), what is your status (print variables) or how the execution behaves from there (stepping)


> enough to reproduce your issue.
>> Uh well, as it happens I'm not exactly a very good coder
>> and most of my code is so highly interdependent upon itself
>> that I can't easily separate one part from another.
>> So, including only part of it might prove unfeasible...
It would be a good exercise if you can isolate the issue. Until then, if you've got to upload the whole project then do so.
I'll recommend to use github in that case. Also include an example user input, and expected output.


> I don't know how to use a debugger and honestly don't know where to start.
http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks
set a breakpoint in main() and step into your whole program.


About your third point, there is a problem in the communication. Your description of the problem is too vague, and I have no idea about your program.

when you say "freeze", ¿how is the processor usage?
Hey...uh, well, I just got my new computer, brand new, and I don't know why but it works just fine now. I'm not going to complain. Whatever. Thanks for the help.
Topic archived. No new replies allowed.