Hi Daniweb Community :),

I'm working on an SDL/C++ project, using the VC++ IDE. There is too much code to put it on here, but I'll give you an outline:

The program works, but there is one thing that doesn't. The resulting .exe file shuts down immediately when it is run from the folder, but works fine when it is run inside the IDE. I had exactly the same problem when I did the project in Code::Blocks. The real problem is that you can't distribute, fx a game, to your friends or anyone when the .exe file does not work. The .dll files are all in the same folder as the .exe file, as required.

Thanks in advance for your help!

put some debug print statements in the program so that you can try to trace what it is doing.

So what you are saying is that there is a bug/error in the program that the compiler doesn't catch, so that the program can still somehow be run inside the IDE, but not from the folder in which it is located?

EDIT: Forgot to mention that debug statements are already in place.

You may need more debugging statements. In general you need to post more descriptive narratives than "it doesn't work". When running the .exe version does the screen show at all? If the screen shows in exe version then what do you see when running in debug mode that you don't see in when running in the exe mode.

You may need more debugging statements. In general you need to post more descriptive narratives than "it doesn't work". When running the .exe version does the screen show at all? If the screen shows in exe version then what do you see when running in debug mode that you don't see in when running in the exe mode.

When I run it in debug mode: It works, I see the animation running and I'm able to start/stop it by pressing 's'.

When I run it without debugging: It works, and I see the same

When I run the .exe file from the folder it is in: I momentarily see a window open and the immediately close again. I am unable to see anything but that.

I hope that's a better explanation :icon_cheesygrin:

It's some better. What do you mean by opening it within the folder? or when you run it without debugging?

I doubt it's something simple like not having a line to pause the program in visible mode just before the program exits, but it doesn't hurt to ask, just to be sure.

What compiler and OS do you use? That info may be helpful to someone trying to answer, though it won't help me much.

It's some better. What do you mean by opening it within the folder? or when you run it without debugging?

I doubt it's something simple like not having a line to pause the program in visible mode just before the program exits, but it doesn't hurt to ask, just to be sure.

What compiler and OS do you use? That info may be helpful to someone trying to answer, though it won't help me much.

When I build the program, the resulting .exe file appears in the project's folder on your computer. It is that folder that I'm talking about.

Running without debugging is option in VC++: Debug -> Start without Debugging. If you run it with debugging it notices errors like trying to initialize SDL or SDL_image (library and an addon):

if(SDL_Init(SDL_INIT_EVERYTHING) == -1)
{
      return -1;
}

I have the following statement before main returns:

cin.get();

It does not make a difference however, whether or not it is there.

I'm running Windows XP, and the compiler that comes with Microsoft Visual C++, but I don't know exactly which one it is.

I really hope this helps! :)

I should probably mention that this project is a Win32 Console Application, which might help you guys some more.

Reading this article from wiki, it states that: "Win32 consoles are typically used for applications that do not need to display images.", which could mean that programs (like mine) that do display images, cannot be run from the folder. I'm not entirely sure about this though.

According to a page at the Visual Studio Developer Center, there is a release option that: "When a project or solution is fully developed and sufficiently debugged, its components are compiled in a Release build". I read that it optimizes the speed, but it sounded like what I wanted, so I tried it.

However, after following the instructions on the site and testing the .exe file that appeared in a new folder called 'Release', it still does the same as the 'Debug' one. So, I still can upload a finished game, because noone can open the .exe file.

If I don't make myself clear, there is still a lack of information or you want me to send you the project, please say so.

zip up the project and attach it. Make sure you delete all compiler-generated files.

run it in command line, is it outputting what it is supposed to?

Attached the zip file, it should contain everything you need.

@ SeeTheLite: How do you run it from the command line? I've never really used it.

Almost forgot the .dlls. All of these should be placed in the same folder as the executable.

we need SDL_image.h and SDL_ttf.h too because they were not included in the development package I downloaded with SDL-1.2.13

we need SDL_image.h and SDL_ttf.h too because they were not included in the development package I downloaded with SDL-1.2.13

Yeah, ofc...

Here they are.

Solved! ^^

I needed to put the images and font inside the .exe folder, because the images/fonts are loaded like this: ".\blablabla". I'm guessing that the '.' means "in the same directory as the project/exe" or something similar.

Thanks for your help and advice!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.