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

Thread: SDL.h not found

  1. #1
    Join Date
    Apr 2007
    Location
    Internet
    Beans
    174
    Distro
    Ubuntu 8.04 Hardy Heron

    SDL.h not found

    I'm compiling a program and I have SDL and sdl_gfx installed. My problem is that I'm getting
    Code:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    I have absolutely no idea why because it's in the same folder as SDL.h.
    I'M USING CAPSLOCK.

  2. #2
    Join Date
    Apr 2007
    Location
    Internet
    Beans
    174
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: SDL.h not found

    Bump. I assume people have dealt with this problem before.
    I'M USING CAPSLOCK.

  3. #3
    Join Date
    Dec 2004
    Location
    Northern Europe
    Beans
    222
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: SDL.h not found

    Maybe this will help.
    sudo apt-get install libsdl-gfx1.2-dev libsdl1.2-dev

  4. #4
    Join Date
    Apr 2007
    Location
    Internet
    Beans
    174
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: SDL.h not found

    I already did that. SDL_gfxPrimitives is in the same include folder as SDL.h.
    I'M USING CAPSLOCK.

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

    Re: SDL.h not found

    Quote Originally Posted by Stoodle View Post
    Bump. I assume people have dealt with this problem before.
    Yes, people have been through this issue many times. Did you do any research to find posts describing a similar problem and the solution? I have never used SDL, but I have helped at least several other members with the exact same problem.

    It would be helpful if you posted the gcc (or g++) statement that you are using to compile your code. If indeed you have the SDL library installed, I wager that you neglected to provide the proper path for the file(s) you are including, and/or failed to provide GCC with the appropriate option indicating where the include files are stored on your system. (Note, you will have to do something similar for the shared-object libraries).

    So, in your code, files should be included in a format similar to:
    Code:
    #include <SDL/SDL_gfxPrimitives.h>
    When calling gcc, use the following option:
    Code:
    gcc -I/usr/local/include -c myfile.c
    This will generate the object file. For other modules you may have, repeat the same, of course, substituting the filename.

    To link:
    Code:
    gcc myfile.o [other.o] -L/usr/local/lib -lSDL -o myapp
    As stated earlier, if you have more than one module, then substitute the [other.o] with the appropriate filename(s).

    Btw, I do believe SDL comes with a pkg-config information package. You should be able to do something like:
    Code:
    gcc myfile.c `pkg-config SDL --cflags --libraries` -o myapp

  6. #6
    Join Date
    Apr 2007
    Location
    Internet
    Beans
    174
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: SDL.h not found

    This is what I got. I'm using g++ because I never got around to learning how to compile with gcc.
    Code:
    g++ Core.cpp Capacitor.cpp LedLight.cpp DisplayModule.cpp Control_Switch.cpp Part.cpp Resistor.cpp SiliconDiode.cpp  -lSDL -lSDL_image -lSDL_gfx -lSDL_main
    In file included from microtype.h:8,
                     from Core.cpp:15:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    Core.cpp: In function ‘int main(int, char**)’:
    Core.cpp:118: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:126: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:134: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:142: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:156: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:164: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:172: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:180: warning: deprecated conversion from string constant to ‘char*’
    Core.cpp:184: error: ‘Sleep’ was not declared in this scope
    Core.cpp:189: warning: deprecated conversion from string constant to ‘char*’
    In file included from microtype.h:8,
                     from Part.h:10,
                     from Capacitor.cpp:2:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    Capacitor.cpp:4:23: error: SDL_image.h: No such file or directory
    In file included from microtype.h:8,
                     from Part.h:10,
                     from LedLight.cpp:2:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    In file included from microtype.h:8,
                     from DisplayModule.cpp:2:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    DisplayModule.cpp:5:23: error: SDL_image.h: No such file or directory
    In file included from microtype.h:8,
                     from Control_Switch.cpp:2:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    Control_Switch.cpp:5:23: error: SDL_image.h: No such file or directory
    In file included from microtype.h:8,
                     from Part.h:10,
                     from Part.cpp:5:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    In file included from microtype.h:8,
                     from Resistor.cpp:2:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    In file included from microtype.h:8,
                     from SiliconDiode.cpp:2:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    When I search the SDL include folder, I get this.
    Code:
     ls /usr/include/SDL/
    begin_code.h     SDL_framerate.h           SDL_loadso.h    SDL_stdinc.h
    close_code.h     SDL_getenv.h              SDL_main.h      SDL_syswm.h
    SDL_active.h     SDL_gfxPrimitives_font.h  SDL_mixer.h     SDL_thread.h
    SDL_audio.h      SDL_gfxPrimitives.h       SDL_mouse.h     SDL_timer.h
    SDL_byteorder.h  SDL_gfxPrimitives.h~      SDL_mutex.h     SDL_ttf.h
    SDL_cdrom.h      SDL.h                     SDL_name.h      SDL_types.h
    SDL_config.h     SDL_imageFilter.h         SDL_opengl.h    SDL_version.h
    SDL_cpuinfo.h    SDL_image.h               SDL_platform.h  SDL_video.h
    SDL_endian.h     SDL_joystick.h            SDL_quit.h
    SDL_error.h      SDL_keyboard.h            SDL_rotozoom.h
    SDL_events.h     SDL_keysym.h              SDL_rwops.h
    See, this was for a project at school and I had already installed SDL and used it here on my Linux box. What I'm adding to it now is an extension because...it can't draw primitives...
    This no such file error is occuring in a library file.
    I have looked this up but I just haven't found anything.

    In SDL_gfxPrimitives.h, the include is
    Code:
    #include <SDL/SDL.h>
    Of course, this is after trying the default
    Code:
    #include "SDL.h"
    and
    Code:
    #include "SDL/SDL.h"
    Last edited by Stoodle; May 10th, 2009 at 01:54 PM. Reason: Added code from SDL_gfxPrimitives.h
    I'M USING CAPSLOCK.

  7. #7
    Join Date
    Feb 2007
    Beans
    4,045
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: SDL.h not found

    Quote Originally Posted by dwhitney67 View Post
    Code:
    gcc myfile.c `pkg-config SDL --cflags --libraries` -o myapp
    Code:
    pkg-config sdl --cflags    #for compiler flags
    pkg-config sdl --libs      #for linker flags
    
    # And all in one
    gcc myfile.c $(pkg-config sdl --cflags --libs) -o myapp

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

    Re: SDL.h not found

    Note that header files are only searched for in the following directories:
    • The directory from which you compile
    • Those listed as the include paths.

    They are not searched for in a path relative from where they called. So I assume that you have the line "#include <SDL/SDL.h>" in your C/C++-files. This is *wrong* and leads to the errors you get. The SDL documentation states (or should state) that you have to do: "#include <SDL.h>".

    In order to compile your program then, you have to add the SDL include path to your includes path, i.e. by adding the option "-I/usr/local/include/SDL" or something like that to the gcc/g++ call (or use the pkg-config approach above).

    Finally: Never change files in "/usr/include" yourself. - This will lead to a mess.
    Last edited by Zugzwang; May 10th, 2009 at 01:59 PM.

  9. #9
    Join Date
    Apr 2007
    Location
    Internet
    Beans
    174
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: SDL.h not found

    I know that they come from /usr/include/SDL and they are not relative to the code. I don't have this problem with any of the other include files.

    I forgot, what was the difference between <> and ""?
    I'M USING CAPSLOCK.

  10. #10
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,288
    Distro
    Kubuntu

    Re: SDL.h not found

    Quote Originally Posted by Stoodle View Post
    This is what I got. I'm using g++ because I never got around to learning how to compile with gcc.
    GCC is the Gnu Cross Compiler, of which gcc and g++ are two of the products of this package. If I recall, using gcc to mimic g++ can be done with 'gcc ... -lstdc++'.

    Code:
    g++ Core.cpp Capacitor.cpp LedLight.cpp DisplayModule.cpp Control_Switch.cpp Part.cpp Resistor.cpp SiliconDiode.cpp  -lSDL -lSDL_image -lSDL_gfx -lSDL_main
    In file included from microtype.h:8,
                     from Core.cpp:15:
    /usr/local/include/SDL/SDL_gfxPrimitives.h:17:17: error: SDL.h: No such file or directory
    ...
    Quote Originally Posted by Stoodle View Post
    When I search the SDL include folder, I get this.
    Code:
     ls /usr/include/SDL/
    ...
    This is not the folder that gcc is seeing. You're looking at /usr/include/SDL (which btw, is the typical install directory for the SDL headers), and the compiler is looking at /usr/local/include.

    Determine where your SDL headers/libraries are located at, and tell this too 'g++'. See geirha's post.

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
  •