SDL (Simple DirectMedia Layer) is a C library for writing games. This blog post should help you get started with developing SDL games.
If you prefer to use Visual Studio, this article will be irrevelant to you. Follow the steps at lazyfoo.net instead. I'd suggest that you make use of property sheets. That way you'll need to do the configuration only once.
I've tested this on a few environments, here are the important steps:
xcode-select --installand follow the steps.
brew install sdl2 --universal.
sudo apt-get install clangor
sudo apt-get install build-essentials
sudo apt-get install libsdl2-dev
Sorry, but I just haven't been able to make the time for this. If you're on Windows 10, you should be able to use the Ubuntu 16.04 steps on Windows Subsystem for Linux (WSL).
To build a program you'll need to run:
clang++ filename.cpp -lSDL2 -g or
g++ filename.cpp -w -lSDL2. You can then run the output with
While including SDL, make sure the include statement is
you're on windows, or you can't get it to work with the above steps for any reason I'd suggest you check this out at lazyfoo.net or leave a comment below. That site also has instructions on setting up IDEs.
BTW, if you're on Windows I've got a question for you: Whyyy?
I've always wanted to do that :p
To make sure your setup is working properly, clone this repository and build one of its subfolders with:
# Clone the repository git clone https://github.com/gldraphael/LazyFoo.git # Go to the 4th tutorial ... cd LazyFoo/4 # ... and build it make # Run the executable ./a.out
Makefile uses clang. If you want to use
g++ instead, run
g++ main.cpp -w -lSDL2 instead of
There are many sites that can help you learn SDL. Just make sure the tutorials you're referring to use SDL2. SDL2 has significant changes compared to SDL 1.2 and its predecessors.
Three sites I'd recommend:
When I started learning SDL in 2011, I was just starting out with C++ too, and I could follow nothing but LazyFoo back then. I still recommend LazyFoo, especially if you're new to programming.