I set SDL2 and SDL_image 2 in Code::Blocks on windows and now I get an error: “fatal error: SDL.h: No such file or directory” Can someone help, everything seems okay. My includes look like this:
The error is in SDL_Image.h line 27: #include “SDL.h” . It works fine only with SDL, the problem is in SDL_image. What do you suggest?
Fixed: I included SDL2 in the compiler path. I was wondering which IDE should I use for sdl and I came to conclusion, that Code:Blocks is a good one.
The official stance of SDL folks is that there’s no canonical place where the SDL2 headers are supposed to go, and so developers should put the headers wherever they like and just add that location to the compiler’s project header search path so that SDL.h can be accessed via
They even conveniently ship a handy
sdl2-config executable to help you do that (if your build system supports it), or a
sdl2-config.cmake cmake package script if you’re a cmake user.
But with that said, yes, everything puts the header files inside an SDL2 folder and Linux/Mac distributions tend to put that inside a default system include path, and so it’s kind of natural to want to want to include them using <SDL2/SDL.h>. But you’re supposed to use
sdl2-config.cmake to map that
SDL2 directory as a project include path and then do
#include "SDL.h" in your code to include the headers via that project include path, instead of via the absolute system path.
(but I’ll confess that I’ve never actually done that and I’ve more than once been guilty of editing SDL_image.h’s #include line to just Make It Work. I am very sorry, Sam! )