csdlsdl-2sdl-image

SDL_image.h fatal error: No such file or directory


I am using Debian and i downloaded SDL_image.h succesfully. (sudo apt-get install libsdl2-image-dev)

I wrote a simple code to tell if it sees PNG images, but I'm getting an error.

Code:

#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL_image.h>


int main(){
    if (SDL_Init(SDL_INIT_VIDEO) < 0) printf("ERROR SDL_Init() - VIDEO");
    if (IMG_Init(IMG_INIT_PNG) < 0) prinft("ERROR IMG_Init() - PNG");
    
    char fileName[50] = "im.PNG";
    SDL_Texture *image = IMG_Load(fileName);
    if (image == NULL) printf("ERROR image == NULL");

    SDL_FreeSurface(image);
    return 0;
}

I compiled it on the command line as follows

gcc SDL_learnT.c -w -lSDL2 -o SDL_learnT

And i am getting Error = "fatal error: SDL_image.h No such file or directory"

I tried to do the following but the result did not change #include <SDL2_image.h> or #include <SDL2/SDL_image.h>


Solution

  • SOLUTION

    It should be <SDL2/SDL_image.h> not <SDL_image.h>
    
    Compiling with gcc should be as follows (Command Line)
    
    $gcc FILENAME.c -o OUTNAME -w -lSDL2 -lSDL2_image