Wednesday, July 11, 2012

Setting up SDL on the Linux Command Line

Deprecation Notice:

I've been updating the lessons now that SDL2 is officially released, please visit my new site on Github that has updated lessons and improved code.


Let's make sure everything is installed properly. Open up a new C++ file and enter: Note that on linux you may need to instead include SDL/SDL.h or SDL2/SDL.h depending on your configuration, although in my tutorials the code will say SDL.h

And compile the file using
g++ -Wall YOURFILENAME.cpp -o SDL_Test -lSDL2

Note: If g++ fails to find your libraries or header files, you probably need to specify the paths to them, using some extra flags
-L /path/to/libs/ -I /path/to/includes/

If you get any errors, make sure you've followed each step.

End of Lesson 0

If you're having trouble setting up SDL please leave a comment below.

I'll see you again soon in Lesson 1: Hello World

3 comments:

  1. Linux users to be specific, may need to do

    #include "SDL2/SDL.h"

    ReplyDelete
    Replies
    1. Thanks for the tip! I'll update the post.

      Delete
  2. The problem is not exactly with Linux, but with how people setup SDL on Windows. Having a directory for the SDL/SDL2 includes in the compilers path should be the best way to do it. Instead of pointing the compiler to the contents of the SDL/SDL2 directory. But, this come from the early SDL days and there's not much to do about it :(.

    ReplyDelete