Jump to content
  • Advertisement
Sign in to follow this  
Poitertjuh

[SDL & C++] Creating an exe file.

This topic is 3312 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

I realise this has probably been asked before, but I couldn't find any answers using search. So I made a game in Visual C++ 2008 with SDL libraries, and even though it's the worst game ever, I feel like showing it off to my friends. When I'm in VC++ I can just run it, no problem, but I want to be able to open it with any pc. That's where the .exe comes in. I found a .exe in the Visual Studio 2008/Projects/<project name>/Debug Folder, but doubleclicking it told me it couldn't find certain dll files. So I just copied and pasted everything it needed (bmp, wav, and dll files) into the Debug folder, right next to the .exe file. So what happens now? Windows finds a fatal error, the game crashes, end of story. I know I'm pretty much a nitwit when it comes to game programming. I'm making many mistakes, looking around, learning in the process. Anyway, if anyone of you could help me, thanks a lot! (I'm not really sure if this is in the right forum but since I'm using SDL I thought it might be.)

Share this post


Link to post
Share on other sites
Advertisement
This has nothing to do with SDL. There are some extra hoops you must jump through when distributing an app made with VC++ 2008. The best resource for explaining the necessary steps is MSDN Dev Center. You just have to read this stuff and deploy according to their instructions.

Recently, I downloaded an open source game SuperTuxKart whose Windows release was made with VC++. Their deployment was painless to me the user, so it is possible just to make an installer that takes care of everything for the end user. Maybe you can look at that as an example.

Edit: I use Code Blocks since I write code on Windows and Linux so I am afraid I do not have any first hand knowledge to offer, other than the link.

Share this post


Link to post
Share on other sites
Problem here could probably be how Visual Studios changes the running directory of the program if you run it from within Visual Studios. When you run it directly from the .exe, it will use the default running directory (the one the .exe is in). Copying files to the .exe's folder is good, but it sounds like you may have missed something. Make sure you have all .dlls files (eg: SDL.dll)in that folder also.

What error do you get? Give us the details, and it's possible we'll know instantly. Otherwise, you might need to put checks at every place where you load in a file to log errors reading those files and double check all file paths inside your program.

To run your program on other computers, there's some more steps, but making sure that you can run it on your own computer is the first step!

Share this post


Link to post
Share on other sites
Ok I feel like an idiot now. I obviously missed something, because I just copied everything into the debug folder and it DOES work now.

But Ezbez, you're saying there are some other steps needed to run it on other computers? could you please tell me what those steps are? Step 1 is complete because I can run it on my own pc now.

Thanks in advance.

Share this post


Link to post
Share on other sites
Step 2:

Compile it in Release mode and try running that as you've done for the Debug one.

Step 3:

Try the Release-mode-compiled version on another computer (one without Visual Studios on it). If it works, you're all set (it won't). If it doesn't work, install Visual Studio Redistributables on the computer that needs to run it.

Step 4:

Try again, see if it works. If so, then awesome! If not, post here with the complete error message and details of anything relevant done to the target computer.

Share this post


Link to post
Share on other sites
thanks!

I ran in to a little problem though.
When I tried to build it in the release version, i get the following error:

1>Main.obj : error LNK2001: unresolved external symbol _SDL_Init

It repeats the error for every SDL function I called. I understand that it's unable to find the libraries or SDL header files, but I can't seem to figure out where I'm supposed to place them.

This problem does not show up when I try to build it in debug.

I hope you can help me. Thanks in advance.

Share this post


Link to post
Share on other sites
In VC++ you have to set the project properties for every configuration seperately. So you probably haven't added the the requred .lib files for the Release build.

So, change your project back to Debug and have a look around the project properties. Somewhere under Linker->Input (I think) you should find a list of .lib files to add to your project (sdl.lib, sdl_main.lib and maybe some more). Just copy them, change back to Release and add them at the same place.

Share this post


Link to post
Share on other sites
Ah.... I thought it would know what libs to look for because I added them already... didn't know I had to redo it once I set it to release. Thanks a lot, I got the release version working on my own computer now. If I have problems with the next 2 steps I'll tell you, but I think it's pretty straight forward. Thanks a lot!

Oh and if my game ever turns out to become at least decent (I'm trying pretty hard, that's for sure), I'll post it on this forum.

Share this post


Link to post
Share on other sites
If I knew how to do it I'd make a step by step article for everyone and post it up here. I see this question all the time pop up and I know myself I've looked into it and MSNs article (at least the one I saw, there may be multiples) was a mess and didn't explain much : /


Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!