Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Linking SDL_image problem

  1. #1
    Join Date
    Oct 2005
    Location
    USA
    Beans
    46
    Distro
    Ubuntu 14.04 Trusty Tahr

    Linking SDL_image problem

    I assume that this will be a fairly easy fix.

    Okay I installed "libsdl-image" automatically.

    Then when I compiled my program and included it, it said it did not exist.

    So I downloaded it manually and just put the header file into the SDL directory.

    So now it can locate the header file but when I try to link it, it says this:

    /usr/bin/ld: cannot find -lSDL_image
    collect2: ld returned 1 exit status


    How do I go about fixing this manually since I already tried reinstall of SDL, SDL-imageimage, SDL-all, gcc, g++. And that did not help.

  2. #2
    Join Date
    Oct 2007
    Beans
    1,914
    Distro
    Lubuntu 12.10 Quantal Quetzal

    Re: Linking SDL_image problem

    Did you also install the package "libsdl-image1.2-dev"? Installing the -dev packages is required for compilation.

  3. #3
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,285
    Distro
    Kubuntu

    Re: Linking SDL_image problem


  4. #4
    Join Date
    Oct 2005
    Location
    USA
    Beans
    46
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Linking SDL_image problem

    Aha that was it I didn't install the Dev files. Now I feel dumb.

    I haven't installed it in so long I have always just had it so I didn't remember that.

  5. #5
    Join Date
    Feb 2009
    Beans
    4

    Re: Linking SDL_image problem

    Hum, i have installed the libsdl-image1.2-dev package but i still get the "/usr/bin/ld: cannot find -lSDL_Image" error.
    Is there another thing i forgot?

  6. #6
    Join Date
    Feb 2009
    Beans
    72

    Re: Linking SDL_image problem

    I'm not on Ubuntu to test this at the moment... but I think you need to compile with either:

    -lSDL_image
    -lSDL_Image
    Worth a try I guess.

  7. #7
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,285
    Distro
    Kubuntu

    Re: Linking SDL_image problem

    Quote Originally Posted by bourriquet42 View Post
    Hum, i have installed the libsdl-image1.2-dev package but i still get the "/usr/bin/ld: cannot find -lSDL_Image" error.
    Is there another thing i forgot?
    Show us the GCC compile/link statement you were using to build your app. Maybe the problem lies there?

  8. #8
    Join Date
    Feb 2009
    Beans
    4

    Re: Linking SDL_image problem

    Code:
    g++ -Wall -I/usr/include/   -c -o lesson3.o lesson3.c
    g++ -Wall -I/usr/include/ -o lesson3 -L/usr/X11R6/lib  lesson3.o -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm -lSDL -lSDL_Image  
    /usr/bin/ld: cannot find -lSDL_Image
    collect2: ld a retourné 1 code d'état d'exécution
    make: *** [lesson3] Erreur 1
    rm lesson3.o

  9. #9
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,285
    Distro
    Kubuntu

    Re: Linking SDL_image problem

    Did you reference the link in this post?

    Try using `pkg-config sdl --libs` in lieu of specifying the SDL library yourself.

    When compiling your file, you may need to specify `pkg-config sdl --cflags`.

    Btw, many people seem to make the mistake of thinking that their CFLAGS are going to make a difference during the link stage of building their application; it won't. Thus you can leave out the -Wall -I/usr/include when you are linking your object files with the libraries.

    Try:
    Code:
    g++ -Wall -I/usr/include/ `pkg-config sdl --cflags` -c -o lesson3.o lesson3.c
    g++ -o lesson3 -L/usr/X11R6/lib  lesson3.o -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm `pkg-config sdl --libs`
    You may want to verify if you really need to specify all of those other libraries.

  10. #10
    Join Date
    Feb 2009
    Beans
    4

    Re: Linking SDL_image problem

    Code:
     pkg-config sdl --libs --cflags
    -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL  -lSDL
    Should i conclude that sdl-image has not been installed correctly?

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •