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

Thread: SDL/SDL_image.h: No such file or directory

  1. #1
    Join Date
    Aug 2008
    Beans
    212

    SDL/SDL_image.h: No such file or directory

    A while ago I wrote a program that I am now trying to run on a new computer and I am getting the following errors.
    Code:
    hopchewer@hopchewer:~/Programming/gaming/Pong_file$ g++ -o pong pong.cpp -lSDL_image
    pong.cpp:5:27: error: SDL/SDL_image.h: No such file or directory
    pong.cpp: In function ‘SDL_Surface* load_image(std::string)’:
    pong.cpp:128: error: ‘IMG_Load’ was not declared in this scope
    I installed the following: libsdl1.2-dev libsdl1.2debian prior to running the program. How do I get this running and get SDL to work again?

  2. #2
    Join Date
    Aug 2005
    Location
    Fargo, ND, USA
    Beans
    1,499
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: SDL/SDL_image.h: No such file or directory

    You also need libsdl-image1.2-dev. You can use http://packages.ubuntu.com/ to search for packages containing a certain filename.
    Help yourself: Search the community docs or try other resources.
    Quote Originally Posted by Henry Spencer
    Those who do not understand Unix are condemned to reinvent it, poorly.
    Let science use your computer when you aren't: Folding@Home.

  3. #3
    Join Date
    Feb 2008
    Location
    readlink("/proc/self/exe"
    Beans
    1,120
    Distro
    Ubuntu Development Release

    Wink Re: SDL/SDL_image.h: No such file or directory

    Next time:

    Code:
    apt-get install apt-file
    apt-file update
    apt-file search SDL_image.h
    Which outputs the package where SDL_image.h is in.
    In a world without walls and fences, who needs Windows and Gates?
    Linux is like a wigwam.... no Gates, no Windows but Apache inside!
    http://www.debianadmin.com
    apt-get install libstdc++6-4.3-doc

  4. #4
    Join Date
    Feb 2008
    Location
    readlink("/proc/self/exe"
    Beans
    1,120
    Distro
    Ubuntu Development Release

    Wink Re: SDL/SDL_image.h: No such file or directory

    Quote Originally Posted by jpkotta View Post
    You also need libsdl-image1.2-dev. You can use http://packages.ubuntu.com/ to search for packages containing a certain filename.
    Code:
    apt-cache search PROGRAMNAME
    apt-file search filename.h
    Also, you need to link to this library.
    In a world without walls and fences, who needs Windows and Gates?
    Linux is like a wigwam.... no Gates, no Windows but Apache inside!
    http://www.debianadmin.com
    apt-get install libstdc++6-4.3-doc

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

    Re: SDL/SDL_image.h: No such file or directory

    You may also get greater mileage if you do something like:
    Code:
    g++ -o pong pong.cpp `pkg-config --cflags --libs sdl` -lSDL_image

  6. #6
    Join Date
    Aug 2008
    Beans
    212

    Re: SDL/SDL_image.h: No such file or directory

    If I use:
    Code:
    g++ -o pong pong.cpp `pkg-config --cflags --libs sdl` -lSDL_image
    or:
    Code:
    g++ -o pong pong.cpp -lSDL_image
    The program compiles and runs. When I use my Makefile I get a ton of errors.

    Output with Makefile:
    Code:
    hopchewer@hopchewer:~/Programming/gaming/Pong_file$ make
    g++ -O2 -Wall -Werror -ansi   -c -o pong.o pong.cpp
    cc1plus: warnings being treated as errors
    pong.cpp: In member function ‘void Paddle1::get_input()’:
    pong.cpp:264: error: enumeration value ‘SDLK_UNKNOWN’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_FIRST’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_BACKSPACE’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_TAB’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_CLEAR’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_RETURN’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_PAUSE’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_ESCAPE’ not handled in switch
    pong.cpp:264: error: enumeration value ‘SDLK_SPACE’ not handled in switch
    ...
    pong.cpp:272: error: enumeration value ‘SDLK_BREAK’ not handled in switch
    pong.cpp:272: error: enumeration value ‘SDLK_MENU’ not handled in switch
    pong.cpp:272: error: enumeration value ‘SDLK_POWER’ not handled in switch
    pong.cpp:272: error: enumeration value ‘SDLK_EURO’ not handled in switch
    pong.cpp:272: error: enumeration value ‘SDLK_UNDO’ not handled in switch
    pong.cpp:272: error: enumeration value ‘SDLK_LAST’ not handled in switch
    make: *** [pong.o] Error 1
    Makefile:
    Code:
    CXXFLAGS = -O2 -Wall -Werror -ansi
    LDLIBS = -lSDL_image -lpthread
    INCLUDE = .
    PROG = Pong
    NAME = Pong
    SRCS = pong.cpp
    OBJS = pong.o
    
    $(PROG): $(OBJS)
    		$(CXX) -o $(PROG) $(OBJS) $(LDLIBS)
    		#mv $(PROG) ..
    
    # How to make the object files:
    
    -include deps.mak
    
    deps:
    		$(CXX) -MM $(SRCS) > deps.mak
    
    # Cleaning target (only works with fileutils):
    
    clean:
    		$(RM) $(OBJS) $(PROG)
    I am not sure why I am getting this problem with my Makefile. Everything worked on my laptop.

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

    Re: SDL/SDL_image.h: No such file or directory

    Maybe because you are optimizing? Maybe because of the -ansi option? Maybe because of the -Werror?

    You are comparing apples to oranges.

    My bet is that it is the optimization flag in conjunction with -Wall and -Werror that are causing you grief. Account for the other possible enum values in your switch statement, or at a minimum place a default case, and I bet the warnings/errors will go away.

  8. #8
    Join Date
    Aug 2008
    Beans
    212

    Re: SDL/SDL_image.h: No such file or directory

    Account for the other possible enum values in your switch statement, or at a minimum place a default case, and I bet the warnings/errors will go away.
    A default case didn't clear up the errors. Removing -Wall removed the errors.
    Code:
    -O2 - Wall -Werror -ansi
    Am I not supposed to be adding all these? I don't know much about Makefiles. I've just always included these and have never had any problems.

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

    Re: SDL/SDL_image.h: No such file or directory

    What you should have done is add a default case to your switch-block. The compiler flags are fine, but as you found out, the -Wall is causing the warning to show up, and the -Werror is causing the warning to be treated as an error.

    Code:
    void Paddle1::get_input()
    {
       SDLKey value;
    
       ...
    
       switch (value)
       {
          case SDLK_UNKNOWN:
              ...
              break;
    
          case SDLK_FIRST:
              ...
              break;
    
          ...
    
          // ADD a default case and the warning goes away!!!
          default:
              ...
              break;
       }
    
       ...
    }
    Btw, the compiler options have nothing to do with Makefiles. You could have just as easily used those options on the command line.

  10. #10
    Join Date
    May 2009
    Beans
    522

    Re: SDL/SDL_image.h: No such file or directory

    For debugging purposes, I never use optimization flags. All levels of optimization include the optimization "-fomit-frame-pointer" which means that the frame-pointer is not stored in a register. Because of this, tools such as gdb or valgrind are unable to step through your code.

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
  •