Closed Sondro closed 1 year ago
Does it actually fail though? RE bundles it's own version of the SDL headers.
Yeah, it says: fatal error:SDL.h: No such file or directory #include
Ah alright, I'll have to look into this further when I'm at my computer as there might be other things that need tweaking after this change.
I'm confused, how does it attempt to compile with SDL1 at all?
The build commands invokes pkg-config --cflags x11 sdl2 SDL2_image openal sndfile zlib gl
which adds (among others) -I/usr/include/SDL2
, meaning #include <SDL.h>
should resolve to /usr/include/SDL2/SDL.h
All the SDL1 headers are in /usr/include/SDL
; how is that SDL.h making it into your build at all?
I solved the problem without stackoverflow, but you can see a similar problem & solutions posted there: https://stackoverflow.com/questions/10488775/sdl-h-no-such-file-or-directory-found-when-compiling
As several of the comments there explain, one way to include headers is to tell the compiler WHERE to find the headers via one of 3 methods:
-I/usr/include/SDL2
directivepkg-config --cflags sdl2
to do thatsdl2-config --cflags
to do that.We are using the 2nd method, but we're also looking up SDL2_image
; between that and sdl2
, at least one of them should add the proper search path.
If it's genuinely not finding the proper SDL header for you, then something is uniquely wrong with either your system, your distro, or your install of SDLs 1 and 2.
IMO, You'd be better served in finding out why the pkg-config command isn't including the correct search path via cflags, rather than changing the code to include the header relative to /usr/include/
.
As several of the comments there explain, one way to include headers is to tell the compiler WHERE to find the headers via one of 3 methods:
- adding an explicit
-I/usr/include/SDL2
directive- using
pkg-config --cflags sdl2
to do that- or using
sdl2-config --cflags
to do that.We are using the 2nd method, but we're also looking up
SDL2_image
; between that andsdl2
, at least one of them should add the proper search path. If it's genuinely not finding the proper SDL header for you, then something is uniquely wrong with either your system, your distro, or your install of SDLs 1 and 2. IMO, You'd be better served in finding out why the pkg-config command isn't including the correct search path via cflags, rather than changing the code to include the header relative to/usr/include/
.
This is the accepted answer.
Fixes # Compile will fail on systems that have SDL1 installed (which is still updated for older apps like Cube1 -- this version works on both & should be SDLx future proof).
Changes proposed in this request: SDL.h to SDL2/SDL.h