Search This Blog

Wednesday, January 15, 2020

Installing SDL 1.2.15

If you want to write programs using SDL you'll need to download it.  In this post I'll show you how to obtain and install the development libraries for SDL 1.2.15 for Visual Studio 2019.  (Note that version 1.2.15 of SDL is superseded by version 2.  I'll write a separate post for that version!)

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.

First we need to find and download the SDL library from their website.


On that page you'll find several different options - Source Code, Runtime, and Development.  You're looking for the Development one for "Win32 Visual C++".  (Note that I'm not linking directly to that download archive since the location or version may change.)

Once you've downloaded the package, extract it to a sensible location.  I like to have all my development work in one location.  In my case, I put everything into "C:\Dev" in appropriate folders.  In this screenshot you can see SDL-1.2.15 along with other libraries I've installed.  (The "Projects" folder is where I point Visual Studio towards to store all my projects.)


Go into the project properties and we'll begin to tell Visual Studio how to find SDL so that we can use it.
Use the wrench on the project head

Select Configuration Properties.  Ensure that Platform is set to x64 since we're using the 64-bit libraries.  Then select C++ Directories and set the Include and Library Directories to the location of the SDL include and lib folders that we extracted earlier.

In my case,

  • C:\Dev\SDL-1.2.15\include
  • C:\Dev\SDL-1.2.15\lib\x64

 If you select either "Include Directories" or "Library Directories" there will be a corresponding drop down context to the right.  From there you can "Edit" and use the ellipsis (...) to open a dialog that you use to locate the correct folder.

Include and Library Directories
Find and select the SDL include directory
Find and select the SDL lib directory

We now need to set the library dependencies.  Find Linker / Input in the properties and set Additional Dependencies to include SDL.lib.  Do not remove anything from the line; just add SDL.lib.

Set Additional Dependencies
Make sure you confirm all the updates and return back to the editor.  SDL 1.2.15 is now complete.

Once we have the project properties all set up we're ready to create a simple "Hello World" using SDL.  It may seem a waste of time to do (yet another) Hello World test, but when you're including external libraries it is really best that you make sure the tool chain won't break into pieces when you use them.  Hello World will make sure that you have a usable working environment.

We'll do that in the next post.  As always, please let me know how I can improve this post.

No comments:

Post a Comment