Skip to content

Installation

H@di edited this page Apr 18, 2020 · 14 revisions
Table of Contents

In order to use RSDL you have to install SDL2 library on your system.

Mac OS users

Install with HomeBrew

  1. Install HomeBrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Install SDL with HomeBrew:
brew install sdl2
brew install sdl2_image
brew install sdl2_mixer
brew install sdl2_ttf
  1. Ensure that following libraries are included in rsdl.hpp:
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_ttf.h>
  1. To compile rsdl.cpp, you have to compile it with -l option to include SDL2, SDL2_image, SDL2_ttf and SDL2_mixer libraries.Run the following command:
g++ [your cpp files] rsdl.cpp -l SDL2 -l SDL2_image -l SDL2_ttf -l SDL2_mixer

Manual Install

  1. Download the latest SDL2 development library dmg file from the SDL website (currently latest version is 2.0.6)

  2. Download SDL2_image development library from this page

  3. Download SDL2_mixer development library from this page

  4. Download SDL2_ttf development library from this page

  5. Now open these dmg files and copy SDL2.framework,SDL2_ttf.framework and SDL2_image.framework files to /Library/Frameworks

  6. Replace SDL libraries inclusion in rsdl.hpp with following ones:

#include <SDL2/SDL.h>
#include <SDL2_image/SDL_image.h>
#include <SDL_mixer/SDL_mixer.h>
#include <SDL2_ttf/SDL_ttf.h>
  1. To compile rsdl.cpp, you have to compile it with -framework option to include SDL2, SDL2_image, SDL2_ttf and SDL2_mixer libraries. Run the following command:
g++ [your cpp files] rsdl.cpp -framework SDL2 -framework SDL2_image -framework SDL2_ttf -framework SDL2_mixer

Linux users

  1. Make sure you have the following apt-get repo:‍ http://us.archive.ubuntu.com/ubuntu (or any other mirror of that) and your apt-get packages list is up to date. Generally you DO NOT need to do this step.

    1. Open your repos list with the following command:
    sudo nano /etc/apt/sources.list
    1. Ensure that following line exists in the file, if it does not exists, add it to the file:
    deb http://us.archive.ubuntu.com/ubuntu trusty main universe

    Note that any other mirror (e.g. ir.archive.ubuntu.com) is sufficient. Also, trusty is the code name of your ubuntu version. Use appropriate codename instead.

    1. Update your apt-get packages list:
    sudo apt-get update
  2. Run command below to install SDL2, SDL2_image and SDL2_ttf packages

sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev 
  1. Ensure that following libraries are included in rsdl.hpp:
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_ttf.h>
  1. To compile rsdl.cpp, you have to compile it with -l option to include SDL2, SDL2_image, SDL2_ttf and SDL2_mixer libraries.Run the following command:
g++ [your cpp files] rsdl.cpp -l SDL2 -l SDL2_image -l SDL2_ttf -l SDL2_mixer

Test Installation

To test your installation download or clone the repository (from this link) and go into the downloaded directory, then run the make command to build the test file.
Finally running ./test.out should come up with a window with UT background. ./examle.out is another example.

cd RSDL   
make    
./test.out
./example.out
Clone this wiki locally