SDL Programming
|
SDL (Simple DirectMedia Layer) is a
cross-platform API for multimedia programming (e.g., games).
The information for using SDL in Windows (e.g., in
Microsoft Visual C++ 6.0) is clear, but I had a hard time finding
useful information for using SDL in GNU/Linux. This page documents what
I've learned. I'd like to know if there are better ways to do what
I'm describing.
This page assumes that all necessary programming tools and SDL
libraries are installed.
|
|
| From the Command Prompt
|
With a terminal window open, I compiled and linked
a simple SDL program named main.c
as follows:
gcc -o main main.c $(sdl-config --cflags --libs)
The example above assumes that the program doesn't use any extra SDL
libraries. To build a program using libraries SDL_ttf and SDL_mixer, I needed
to indicate that to the linker as follows:
gcc -o main main.c $(sdl-config --cflags --libs) -lSDL_ttf
-lSDL_mixer |
|
| Using Anjuta
|
Anjuta is an integrated development environment (IDE)
for programming in Ubuntu (GNOME). Here's how I'm able to maintain a
SDL project in Anjuta:
In a terminal window, I entered the following commands and noted the
results:
echo $(sdl-config --cflags)
echo $(sdl-config --libs)
I started Anjuta. In the Start
With dialog, I clicked the Application
Wizard button to start a new project. I selected Generic/Terminal
project as the project type. The rest of the options were
straightforward. Anjuta automatically created main.c for me as a basic
"Hello, world!" program.
I had existing program code, so I pasted it over the existing main.c
code.
I then selected Settings>Compiler
and Linker Settings... from the
Anjuta menu. On the Options
tab, I set the Additional
Options
fields as follows:
Compiler Flags (CFLAGS): the value returned by echo $(sdl-config --cflags)
Linker Flags (LDFLAGS): the value returned by echo $(sdl-config --libs)
Additional Libraries (LDADD): if applicable, the references to
additional SDL libraries as described in From the Command Prompt
section above.
My Additional Options
settings are shown below: |
 |
|
| Last Updated: January 21,
2007 |
 |