Eclipse - SDL (Simple Directmedia Layer) - Installation

You like C and C++ but you need some help to access audio, joystick, keyboard, video framebuffer, etc.
That's why you would like to use the SDL library.

But, there is still a problem, you don't know how to install it with Eclipse.

OK, let's try it with this tutorial installation.

1. Installation of SDL with Eclipse on Windows

A. Outside Eclipse

We assume that you have already installed MinGW in this directory: C:\soft\mingw.

Let's get started by downloading the development libraries of your choice on the official website: http://www.libsdl.org/download-1.2.php

So let's take the SDL-devel-LAST_VERSION-mingw32.tar.gz version.

Open it and extract:

  • bin/SDL.ddl
  • bin/sdl-config

into C:\soft\mingw\bin

Then:

  • include/SDL

into C:\soft\mingw\include

And finally:

  • lib/libSDL.dll.a
  • lib/libSDL.la
  • lib/libSDLmain.a

into C:\soft\mingw\lib

So we have now:

C:\soft\mingw\bin\SDL.dll
C:\soft\mingw\bin\sdl-config
C:\soft\mingw\include\SDL
C:\soft\mingw\lib\libSDL.dll.a
C:\soft\mingw\lib\libSDL.la
C:\soft\mingw\lib\libSDLmain.a

B. Inside Eclipse

Open, for example, a C++ project.

Right click its name > Properties (or just use the ALT + ENTER shortcut).
Then C/C++ Build > Settings.

On the right there are multiple tabs.
Select the Tool Settings one.
On the list, click Libraries (sub part of the C++ Linker of your choice, for example MinGW).
On the right, there are two panels: Libraries (-l) and Library search path (-L).

On the first (Libraries), click the + icon to add the following libraries, in the same order or it won't work:

  1. mingw32
  2. SDLmain
  3. SDL

What you are doing there is to add libraries that you have just added before in the MinGW folder.
These libraries can be found in the C:\soft\mingw\lib directory.
They have the .a extension as all libraries in C and C++.

Click Apply and OK to return to your project.

You can now test this setup of SDL on Eclipse with an Hello World tutorial!.