'“SDL.h” no such file or directory found' when compiling

后端 未结 6 929
情深已故
情深已故 2021-01-31 18:07

Here\'s a piece of my current Makefile:

CFLAGS = -O2 -Wall -pedantic -std=gnu++11 `sdl-config --cflags --libs` -lSDL_mixer

I have libsdl instal

6条回答
  •  日久生厌
    2021-01-31 18:44

    header file lives at

    /usr/include/SDL/SDL.h
    
           __OR__
    
    /usr/include/SDL2/SDL.h  #  for SDL2
    

    in your c++ code pull in this header using

    #include 
    
           __OR__
    
    #include     // for SDL2
    

    you have the correct usage of

    sdl-config --cflags --libs
    
           __OR__
    
    sdl2-config --cflags --libs   #  sdl2
    

    which will give you

    -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
    -L/usr/lib/x86_64-linux-gnu -lSDL
    
           __OR__
    
    -I/usr/include/SDL2 -D_REENTRANT
    -lSDL2
    

    at times you may also see this usage which works for a standard install

    pkg-config --cflags --libs sdl
    
           __OR__
    
    pkg-config --cflags --libs sdl2   #  sdl2
    

    which supplies you with

    -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -lSDL
    
           __OR__
    
    -D_REENTRANT -I/usr/include/SDL2 -lSDL2   #  SDL2
    

提交回复
热议问题