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.

Do I have to set up SDL 2.0.3 every time I make a new project?

I tried putting sdl.dll in system32 so that I don't have to include it in my project folders, but that didn't work.

share|improve this question

3 Answers 3

I'm not quite sure what you mean by "setting up SDL". You have to #include headers and link to binaries of libraries for each project.

In Visual Studio, there are so called property sheets that let to share properties between projects. You could create one that contains SDL as linker input but I highly doubt that applying the property sheet is faster than just linking to the library.

share|improve this answer

To use SDL (or any other similarly-packaged dependency), you have to:

  • Add the path to the SDL headers to the additional include directories, so the compiler can find them when you #include "SDL.h" or whatnot.
  • Add the path to the import library (the .lib) to the linker search paths.
  • Actually link against the import library.
  • Distribute the actual DLL next to your shipping executable (or elsewhere in the DLL search path).

The first three steps can be set in the project properties of your project, in the C++ and linker tabs respectively. You can set these ones and use property sheets to save the settings, importing them into a new project. Alternatively you can just set up a basic skeleton project, install it as a Visual Studio template or just create a clone every time you want to start a new project.

Don't try to put your dependencies in system directories like system32 or Visual Studio's standard headers directory. Not only is that bad for you, because you are contaminating what should be an off-limits directory, but it will make it harder to deal with projects that use different versions of a dependency and it doesn't solve the problems of ultimately packaging the dependency for distribution.

If you don't want to keep the copies of your dependencies directly in the folder structure of your project (which is what I'd recommend, since it makes each project an isolated silo that can be configured to build immediately upon checking out from version control with no additional setup), you can create a "ThirdParty" directory to store all your dependencies.

Somewhere in a userspace portion of your hard drive (like in your "My Documents" folder), create a "ThirdParty" directory that has one directory for each dependency (like "SDL" or "GLEW" or "Bullet" and so on). In each of those directories, make a subdirectory for each major version (1.0, 2.0, et cetera) and drop the appropriate dependency, directly as distributed from the vendor, in there.

share|improve this answer

There are 2 things you can do:

  • VS Express: Take the header folder of SDL and put it into the standart header folder. This allows you to use the files like this:

#include "SDL/main.h"

Then you've to put the sdl-lib files into the standart folder for Libs. then you can link the using

#pragma comment (lib,"theLibYouNeedToLink.lib").

For the Dll I'd create a directory called Libs and add this Directory to the path variable. That's the dirty way.

-In other, commercial version of VS you can create Projects and save them as templates. The only thing you've to do after is to place the dll as state above.

share|improve this answer
    
It's very bad practice to install third-party dependencies (like SDL) into the standard include directories for your toolchain. Not only does it potentially interfere with the toolchain's setup, it also makes it cumbersome to deal with multiple versions of a dependency, and makes it harder for you to ultimately package your dependencies for distribution. Every reasonably sane toolchain has options that allow you to configure additional user include and header search paths. –  Josh Petrie May 3 at 17:10
    
I know, that's why I called it the "dirty" way. For my self I prefer using VSC templates. –  Techie May 3 at 18:08

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.