# How to run my game outside of visual c++

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?

• 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

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.

• for release, its way better to just copy the dll +1 – Gustavo Maciel Apr 17 '12 at 23:03

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.

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.

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.