1
\$\begingroup\$

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?

\$\endgroup\$
2
  • 7
    \$\begingroup\$ Is the SDL.dll in the same directory as the executable? \$\endgroup\$
    – Milkboat
    Apr 17, 2012 at 1:39
  • \$\begingroup\$ 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. \$\endgroup\$
    – zacharmarz
    Apr 17, 2012 at 5:15

4 Answers 4

5
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ for release, its way better to just copy the dll +1 \$\endgroup\$ Apr 17, 2012 at 23:03
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .