Skip to content

Instantly share code, notes, and snippets.

@aaangeletakis
Last active February 20, 2024 17:55
Show Gist options
  • Save aaangeletakis/3187339a99f7786c25075d4d9c80fad5 to your computer and use it in GitHub Desktop.
Save aaangeletakis/3187339a99f7786c25075d4d9c80fad5 to your computer and use it in GitHub Desktop.
How do I install SDL on ubuntu?

What you need to do to install SDL is:

#install sdl2
sudo apt install libsdl2-dev libsdl2-2.0-0 -y;

#install sdl image  - if you want to display images
sudo apt install libjpeg-dev libwebp-dev libtiff5-dev libsdl2-image-dev libsdl2-image-2.0-0 -y;

#install sdl mixer  - if you want sound
sudo apt install libmikmod-dev libfishsound1-dev libsmpeg-dev liboggz2-dev libflac-dev libfluidsynth-dev libsdl2-mixer-dev libsdl2-mixer-2.0-0 -y;

#install sdl true type fonts - if you want to use text
sudo apt install libfreetype6-dev libsdl2-ttf-dev libsdl2-ttf-2.0-0 -y;

use

`sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf

to link them, for example:

g++ myProgram.cpp -o myProgram `sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf

if you would like to install all the packages at once, copy and paste this into your terminal

#Oneliner to do the above install
sudo apt update && bash <(wget -qO - https://boredbored.net/sdl2-install)
@aaangeletakis
Copy link
Author

Copy link

ghost commented Feb 16, 2021

I made a Bash script out of this: https://github.com/d26900/Scripts/blob/main/setup.sh

Run it like so: sudo bash setup.sh

If you just want to install the SDL libraries, comment out the other run_installs with a #.
The only thing you need is: run_installs "apt install" "-y" "${apts_sdl[@]}"

@aaangeletakis
Copy link
Author

How is this different from the script I made?
bash <(wget -qO - https://boredbored.net/sdl2-install)

@wpichl
Copy link

wpichl commented Feb 16, 2021

works! thank you! had sum errors but you fixed it!

@aaangeletakis
Copy link
Author

:P

Copy link

ghost commented Feb 19, 2021

How is this different from the script I made?
bash <(wget -qO - https://boredbored.net/sdl2-install)

I wasn't aware of your script, but yours is more concise & short. I designed my Bash script to be more adjustable for different kinds of installs (apt, npm, pip etc.). All you need to do is add the package name to a list pips=("numpy", ...) and then call the run_installs function like so:

run_installs "pip3 install" "" "${pips[@]}"

The first argument is the command, the second argument is an option and the last argument is the list of packages/modules you want to install all at once. Here's another example:

run_installs "apt install" "-y" "${apts_sdl[@]}"

Same structure: <commands> <options> <packages>

Then you need that script as sudo bash setup.sh. Done!

@mmdbalkhi
Copy link

Thankful!

@GH4169
Copy link

GH4169 commented Aug 1, 2023

Thankful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment