Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am having trouble running my game. It works fine when I run it from Visual C++, but when I try to open the .exe, it complains that it can't find SDL.dll.

What should I do in order to play the game?

share|improve this question
7  
Is the SDL.dll in the same directory as the executable? –  Milkboat Apr 17 '12 at 1:39
    
If you are using Total Commander, you can download extension FileInfo. It will provide you list of all DLL's, which your application need and which are both found and missing. –  zacharmarz Apr 17 '12 at 5:15
add comment

4 Answers

up vote 5 down vote accepted

IIRC Visual Studio uses a different current directory than the executable.

To fix, include SDL.dll in the same directory as your .exe file, along with anything else you may need. A symlink for this is a good fix, although I think there's also a setting in VS to choose the path.

share|improve this answer
    
for release, its way better to just copy the dll +1 –  Gustavo Maciel Apr 17 '12 at 23:03
add comment

Find the path to the SDL.dll you're using, let's say it's C:\Path_To_DLL.

Possibly, you've added this path in some VC++ directories dialog. So Visual Studio tweaks your PATH environment variable before you run the game through it.

Or you've set the working directory for debugging your project to this path: by default all DLLs in the working directory can be loaded.

You've got several solutions:

  • As Pubby described, copy SDL.dll or symlink to it in the directory from which you're running your game "externally".

  • Start your game from a batch file where you add this path yourself to your path environment variable:

    RunMyGame.bat:
    set PATH=%PATH%;"C:\Path_To_DLL"
    start MyGame.exe
    
  • Add this path to your global environment variables, in Windows 7 look for "environment variables" in the Windows menu. Then you can just launch your game normally.

share|improve this answer
add comment

Also, consider the possibility of use a installer project offered by Visual Studio. Easy to use and gives you all the necessary stuff to install your games in every MS platform.

share|improve this answer
add comment

Just make sure Visual Studio is set up to run and debug the executable from the directory it is in, and make sure the SDL.dll is also in that directory.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.