What is the general procedure to install development libraries in Ubuntu?

You have to download the source and compile the libs.

You also need some dependencies before compile SDL2. So install these packages first:

sudo apt-get install build-essential xorg-dev libudev-dev libts-dev libgl1-mesa-dev \
libglu1-mesa-dev libasound2-dev libpulse-dev libopenal-dev libogg-dev \
libvorbis-dev libaudiofile-dev libpng12-dev libfreetype6-dev libusb-dev \
libdbus-1-dev zlib1g-dev libdirectfb-dev
  • Method 1: Source code archive
    Now you can go to the libsdl download page and download SDL2-2.0.0.tar.gz, extract the archive (you can extract the archive using tar: tar -xvzf SDL2-2.0.0.tar.gz), cd into the directory created, and run the following commands (don't forget to install the dependencies mentioned above, before starting to compile):

    ./configure
    make
    sudo make install
    
  • Method 2: Mercurial repository
    Another way to install SDL2 is to download SDL from the mercurial repository online. In order to do this you have to install mercurial first:

    sudo apt-get install mercurial
    

    then download SDL (SDL will be downloaded into the directory you're using the terminal)

    hg clone http://hg.libsdl.org/SDL
    

    now go into the downloaded SDL directory and build & install (don't forget to install the dependencies mentioned above, before starting to compile) the libs by running:

    cd SDL
    ./configure
    make
    sudo make install
    

Don't forget to run:

sudo ldconfig

to update the necessary links and cache to the libraries.

Code::Blocks
Add to
Project > Build options > Compiler settings > Other options > -lSDL2

and to
Project > Build options > Linker settings > Other linker options -lSDL2

Remember to add these to the Project options and not only to Debug or Release settings. Also, if you've already wrongly compiled the sources, remember to Rebuild it (CTRL + F11)


You can also do:

If you just want the libraries:

sudo apt-get install libsdl2-2.0

If you want to do development:

sudo apt-get install libsdl2-dev

Tags:

Libraries

Sdl