26

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?

exebook
  • 32,014
  • 33
  • 141
  • 226
  • 2
    Yes, you have to install it yourself. It's not hard, though. Take a look here : http://nothingtocode.blogspot.no/2013/07/setting-up-sdl2-in-ubuntu-or-linux-mint.html – olevegard Feb 05 '14 at 21:03
  • SDL2 is available as packages in Debian unstable, testing, and wheezy-backports. I have no experience with Ubuntu or Mint, but there might be similar packages available for those distributions. – Martin Feb 05 '14 at 21:25
  • 1
    It depend on your version of Ubuntu/Mint, in the newest release, SDL2 and SDL2-image are there in the official repos, but SDL2-ttf didn't make it to get release in the official repos, you'll need to compile it yourself. If you get an older version of the distro, you'll need to compile the library yourself. – jordsti Feb 05 '14 at 21:36
  • Go with compiling yourself. It's really straight forward and will enable you to have latest code fixes. – TPS Apr 13 '14 at 21:42

1 Answers1

40

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.

Leonardo
  • 1,834
  • 1
  • 17
  • 23