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)
I just ran:
sudo apt install libwebp-dev libtiff5-dev libsdl2-image-dev libsdl2-image-2.0-0 -y;
(omitting libjpeg9) an seems to work fine.
I did not use the last two commands. Instead, I just compiled (a really simple program to test sdl) with:
g++ myTest.cpp -o myTest -lSDL2
And then ran the test with:
./myTest
If you are using CLion, just add at the end of the CMakeList:
target_link_libraries(PROJECT_NAME_HERE SDL2)
where PROJECT_NAME_HERE is the name of the first executable in the "add_executable" line (the name of the project's folder). Eventually, you may need to link more than just sdl2:
target_link_libraries(PROJECT_NAME_HERE SDL2 SDL2_image SDL2_ttf SDL2_mixer).