Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing SDL2 on Linux

Tags:

I try to run simple test.cpp from Twinklebar SDL tutorial, I get this error:

test.cpp:2:10: fatal error: 'SDL2/SDL.h' file not found 

So I look up the sdl development package in Ubuntu/Mint:

aptitude search sdl | grep 2 

All I can find is this:

libsdl1.2-dev 

Does this mean my only option is to install from sources?

like image 889
exebook Avatar asked Feb 05 '14 20:02

exebook


People also ask

Where is SDL2 installed Linux?

SDL can be found in /usr/local/lib instead of /usr/lib , which is where I was pointed to after online research.

How do I download SDL2?

Visit http://libsdl.org/index.php, go to Download, and click on the latest version; at the time of writing this book, SDL 2.0 was the latest version. Once you have clicked on the latest version, you may either want to download the development libraries or the runtime libraries.

What platforms does SDL2 support?

Introduction to SDL SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.


1 Answers

It depends which Ubuntu version you are running but yes, there is a libsdl2 package for Ubuntu: http://packages.ubuntu.com/search?keywords=sdl2

The package you want is called libsdl2-dev.

Also, about the #include <SDL/SDL.h> line, it seems the recommended way doing it is by adjusting your compiler flags to add SDL's include pah and use #include "SDL.h". See https://forums.libsdl.org/viewtopic.php?t=5997 for more details on that.

like image 112
Leonardo Avatar answered Sep 18 '22 16:09

Leonardo