DavW's Tutorial Site

C/C++/Game Programming
Web
Music
External Links

Setting up SDL with Eclipse CDT

I have included this guide as this is the setup I will be using for all my game-related tutorials and it will make them easier to follow if you are using the same environment. If you already have a satisfactory IDE/Compiler setup then you probably won't find anything useful here.

What is SDL?

SDL stands for Simple Directmedia Layer and is a cross platform library to access your computer's graphics, sound and input capabilities. In many ways it's like an open-source version of Microsoft's DirectX

What is the Eclipse CDT?

Eclipse is an IDE, originally made for writing Java applications, but with the C Development Toolkit it can be used to write C and C++ programs. Recently a standalone version of Eclipse specifically has been released and is available from the Eclipse download area. Eclipse is a development environment, not a compiler, so if you are using Windows you will need to install MinGW, a windows port of the GCC suite

Installing Eclipse

Once you have downloaded Eclipse, all you need to do is unpack it into a sensible directory and then run the application. You will need a JRE installed in order for Eclipse to run. If you are using Linux it should find all your compilers and tools; if you are using Windows is should find MinGW as long as it is installed

Installing SDL

This step differs depending on your operating system

Setting up your Eclipse project for SDL

Once you have created a new project using the Eclipse new project dialog (either C or C++), you will to add SDL support to the project. In the SDL documentation, you will see reference to an 'sdl-config' script. Unfortunately the limited shell capabilities of Windows mean that we have to put this info in manually. Open up the Project->Properties menu and you will see something like this:

Image of project properties dialog

Go into the C/C++ Build -> Settings page

Image of build settings dialog

Now you can test it with this simple application


#include <SDL/SDL.h>

int main(int argc, char **argv) {
        SDL_Init(SDL_INIT_VIDEO);
        SDL_Quit();
}
 

With any luck, you should be able to compile and run this without errors (although it won't do anything when you run it)

If you want SDL to do anything useful, you'd better read the next tutorial: SDL: The basics