• Advertisement
Sign in to follow this  

[C++] suddenly shutdown on some computers

This topic is 2083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone.

At first: Please excuse my poor English skills :-(.

But let me tell you about my problem:

I wanted to lean how to use SDL. So, at first I read some articles and tutorials. Then I started to code a "game", less a game, more object of my personal study.

I want to create a framework, which grows with my knowledge, where I can implement my ideas and learn out of it.

I have chosen C++ because I already have some Skills in it and want to improve them.

This is my working state:

- I am using Windows 7 64bit Professional

- game-state-machine with actual 2 states (menu & "game"-mode)

- button, timer, tileMap, animation, player, bitmapFont & log classes

- menu state shows a background, with a barely animated cloud and a button, which switches to gameState

- game-mode has a tileMap based background with a level read in by a file, A test of the bitmapFont, and a moveable "hero" with a camara following him (2D if there are any uncertainties) and an exit button.

All this works fine on the computer I coded it on.

Now the actual problem:

I placed the compiled .exe and all necessary .dll's and images in my DropBox because I wanted to test it on my notebook and I direct linked the folder with a fellow student.

On the source computer it isn't possible to start the game, direct ".exe doesn't work anymore..." (- hope I translated this one right -).

On my Notebook (also Windows 7 64bit Professional / no seperate SDL installation) the game starts correct and enters the main Menu, but if click on the new Game button the game closes without any error message.

So I set up my log and logged every step happening (See code & log below).

This way I pointed out that the program exits without a reason (visible for me) after the end of the constructor of the exit button in game state.

(This is the most important problem)

On the computer of my friend (he actually tested with ArchLinux) it works fine in some cases or it isn't startable. (Also interesting, but it's more important for me to get a working version on my notebook, but I am interested in articles/tutorials about using SDL cross platform, because reading windows and linux tutorials and then point out the differences isn't fun, I think.)

Edit: Talked to my friend again, he used windows, too, but I am still interested in cross platform sources.

I am thankful for every help and advice you can provide me. :-)

If new Game button is clicked nxtState is set to STATE_HOME_FARM, changeState is called every gameloop before rendering.

void changeState()
if (nxtState != STATE_NO_CHANGE)
log->log("start change");
if (nxtState != STATE_EXIT)
log->log("delete act");
delete workingState;
switch (nxtState)
log->log("detected home farm");
workingState = new HomeFarm();
log->log("createt state");
log->log("set vars");
actState = nxtState;

This is the constructor of my HomeFarm class.

log->log("create hero");
hero = new Farmer;
log->log("create exit button");
exitButton = new ExitButton(SCREEN_WIDTH/2, SCREEN_HEIGHT-200 , 200, 100, "Buttons/test_button_exit.png");
log->log("create font");

This is the constructor of my ExitButton class

log->log("set vars");
button.x = x;
button.y = y;
button.w = width;
button.h = height;
log->log("load img");
img = loadImg(filename);
log->log("set clip");
log->log("set initial clip");
state = &clip[CLIP_MOUSEOUT];

And finally this is my log.txt created if I run the game on my notebook and try to start a Game.

start change
delete act
detected home farm
create hero
create exit button
set vars
load img
set clip
set initial clip


Edited by Nazzrim

Share this post

Link to post
Share on other sites
What's workingState initialized to? Make sure it's either NULL or a valid state if you're going to be deleting it on the first state change. Edited by Slavik81

Share this post

Link to post
Share on other sites
Right after start up before the gameloop starts working state is initialized to MainMenu state.

int main (int argc, char* args[])
if (init() == false)
log->log ("Error on initialisation...");
return 1;
workingState = new MainMenu();
while (actState != STATE_EXIT)

Share this post

Link to post
Share on other sites

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]So I set up my log and logged every step happening (See code & log below).[/background]

How does your log work? Does it flush each time it is called?

I placed the compiled .exe and all necessary .dll's
How are you building the executable? In release mode? Which DLLs are you including? The "application is not working" message usually means some required DLL is not working.

Share this post

Link to post
Share on other sites
Yes it flushes every time:

void Log::log (std:: string message)
logger << message << std::endl;

I am not completely sure what the difference between release/debug mode (- maybe someone got sources :S? -).
So I use Notepad++ for coding, and mingw32 via cmd for compiling.
I have a bunch of header files for my classes and .ccp files for the actual classes.
I am compiling it using the command "g++ 'all.ccps' -lSDL -lSDLmain -lSDL_image.
This are my includes DLLs:


The first two are there, because my notebook complains if they are not *shame*
The rest are SDL and related DLLs.

I must concede that my DLL skills tend towards zero, but I really like to improve them. ;-)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement