5

Recently I've been playing around with the SDL library and wanted to start using libsdl2-image-2.0-0 along with SDL. I have been trying to get this working with Ubuntu 15.04. I have installed the package using

sudo apt-get install libsdl2-image-2.0-0

The installation appeared to go completely fine but when I try to include the image library in my C++ code with

#include <SDL2/SDL_image.h>

I get an error "fatal error: SDL2/SDL_image.h: No such file or directory" I went and looked where the SDL2 base library was located /usr/local/include/SDL2 and just as the error message said SDL_image.h was not there. I then tried to figure out where the library was using

apt-file search SDL_image.h

When I do this

libsdl-image1.2-dev: /usr/include/SDL/SDL_image.h
libsdl2-image-dev: /usr/include/SDL2/SDL_image.h

both show up as results. This is strange to me since I did not install libsdl2-image-dev. Also when I try to view /usr/include/SDL2/ the folder doesn't even appear to exist which just adds to my confusion.

I then tried to remove libsdl2-image-dev so I could install libsdl2-image-2.0-0 but when I run the command

sudo apt-get remove libsdl2-image-dev

I get

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'libsdl2-image-dev' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.

and when I try to run the command

sudo apt-get install libsdl2-2.0-0

I end up getting

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libsdl2-2.0-0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.

So basically I cannot locate where this library is and so I can't properly link it to my code. Is there a more reliable way to locate where this library is and is there something fundamental I am not understanding in regards to using these supplementary libraries?

A_Sandwich
  • 51
  • 1
  • 1
  • 3

1 Answers1

4

This is strange to me since I did not install libsdl2-image-dev. Also when I try to view /usr/include/SDL2/ the folder doesn't even appear to exist which just adds to my confusion.

apt-file searches the contents of available packages using a database, so it is hardly a surprise that it showed a package which you hadn't installed.

I then tried to remove libsdl2-image-dev so I could install libsdl2-image-2.0-0

Why do you think you have to remove one to install the other, especially when you have already installed it?

is there something fundamental I am not understanding in regards to using these supplementary libraries?

Yes. foo and foo-dev can coexist. If you are a developer, you will probably need both to be installed. foo-dev often depends on foo, so installing it forces foo to be installed as well. In particular, libsdl2-image-dev depends on libsdl2-image-2.0-0.


To conclude, just install the -dev package:

sudo apt-get install libsdl2-image-dev
muru
  • 193,181
  • 53
  • 473
  • 722
  • Thanks for the quick response and thanks for clarifying apt-get search. While it is true that two libraries can co-exist I was trying to avoid having two version of the same library on my system. My main issue is that I can't seem to locate where libsdl2-image-2.0-0 is on my system. I was hoping for some guidance on to how to ascertain the location of an already installed library. That being said I did try to install libsdl2-image-dev and all of it's dependencies but I am having issues with the dependencies. – A_Sandwich Apr 28 '15 at 03:59
  • @A_Sandwich You won't have *two* versions of the library installed. If `libsdl2-image-dev` is some version X, it depends on exactly the same version X of `libsdl2-image-2.0-0`. If you have a dependency problem, post the error you get when trying to install `libsdl2-image-dev`. If you want to see what files are installed by a package, use `dpkg -L `, – muru Apr 28 '15 at 04:03
  • @A_Sandwich A package `libfoo` will provide the compiled files needed to use it, not the header files needed to compile code using it. Those are provided by `-dev` packages. – muru Apr 28 '15 at 04:04
  • @A_Sandwich that is pretty much unreadable in a comment. Please edit your question to add more information. Also, it looks like you're using Rico's PPA. Dependency problems happen when you use PPAs. – muru Apr 29 '15 at 02:12
  • @muru And what about sdl 1.2 ? – Dr.jacky Jan 05 '16 at 10:32
  • @Mr.Hyde what about it? From the question, we can see that the 1.2 and 2 version packages provide the same header - so they can't be installed together (not the dev packages, anyway). – muru Jan 05 '16 at 20:51
  • @muru I want to just install sdl-1.2.15 dev packages. What is package name? libsdl1-2-image-dev is wrong. – Dr.jacky Jan 06 '16 at 08:18
  • 1
    @Mr.Hyde 1.2.15 is not available in the repositories for any version of Ubuntu. The closest is 1.2.12 with some patches; the package name is `libsdl-image1.2-dev`: http://packages.ubuntu.com/search?keywords=libsdl-image1.2-dev – muru Jan 06 '16 at 08:44