To build the projects on Linux we’ll be using a simple makefile that will setup the include and library
dependencies for us. The makefile assumes that your SDL libraries are installed under
and the headers are under
/usr/local/include. These are the install locations if you built the
project through cmake, some more detail on building from source can be found here.
If you’ve installed it through your package manager or placed the libraries
and headers elsewhere you may need to change these paths to match your installation. You can also check the output
sdl2-config with the
--libs switches to locate your install, assuming you haven’t moved it.
If you’re unfamiliar with Makefiles a basic introduction can be found here.
The program we’re building for this lesson is a simple sanity check for SDL. It will
initialize the SDL video subsystem, check for any
errors and then quit.
The source file should be titled
main.cpp, or you can change the main.o build dependency
in the makefile to match your source file.
The program should run successfully but nothing should appear to happen if you’ve configured everything properly. If an error occurs make sure you’ve followed all the setup steps properly.
If you’re having any trouble setting up SDL please send an email or tweet.
I’ll see you again soon in Postscript 0: Properly Finding Resource Paths!