Web Design,Programming,Mobile,iOS/Android,GameDev,IT Businness,eCommerce,Social Media


Thursday, 17 January 2013

Installing SDL libraries and creating your first window on Ubuntu


SDL libraries
SDL is used for creating graphical user interfaces or small games. But if its used correctly you can also create robust graphics applications or games. Simple Direct Media Layer is used to manipulate pixels to create different ui layouts for your applications and even games.

In my other blog posts i discussed about downloading installing and configuring SDL under Windows with Visual Studio. Here we will explain how to get running this library under Ubuntu. Graphics programming under Ubuntu are becoming more popular like even EA started to create games for this platform.

First of all you need to download the essential packages to start writting code. SDL is build with C++ so you will also be coding in C++ programming language. To download the necessary libraries or if you dont know how to compile and run C++ source codes under Ubuntu check this post, where i discuss everything you need to run sample C++ program Hello World.

If you are ready to download and install SDL you can start by opening the terminal and typing this

sudo apt-get install libsdl1.2-dev libsdl1.2debian

The libsdl1.2-dev holds the needed headers and the libraries are in libsdl1.2debian

Now you are ready to start writting some code to test if the library is installed successfully.
Open your favourite text editing software or download geany (i personally recommend it) its great small software which i use all the time when programming especially in C++

Check this blog post if you want to create your new window in SDL library. It doesnt matter that i code in Visual Studio there the code will work either way. If you like to be organized you probably have stored your file in some folder in your file system or home directory. In terminal change dhe directory to the folder where your source files reside with the command cd.

To compile your code you need to type this command in terminal

g++ main.cpp -o sdltest -lSDL

where main.cpp means your source file if you named it main.cpp or if for you is different just change main.cpp with the name of your source file.

sdltest will be the name of our application. Notice in the end we link the SDL libraries with -lSDL. Dont forget this when compiling your code. It will cause errors if you dont link libraries.

To run your first SDL application type this in terminal


Your result should be your first SDL window meaning that you have successfully installed SDL.

Written by

Thank you for taking your time to browse through our blog. We try to build as much rich content base as we can. We focus in modern technologies, computer science design and business.


Post a Comment


© 2013 smartnoob . All rights resevered. Designed by Templateism