# Can't compile program in gcc with SDL\_image

**URL:** <https://discourse.libsdl.org/t/cant-compile-program-in-gcc-with-sdl-image/27449>\
**Category:** SDL Development\
**Created:** [April 7, 2020, 10:49am UTC](https://discourse.libsdl.org/t/cant-compile-program-in-gcc-with-sdl-image/27449 "2020-04-07T10:49:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gupr](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@gupr](https://discourse.libsdl.org/u/gupr)\
**Post date:** [April 7, 2020, 10:49am UTC](https://discourse.libsdl.org/t/cant-compile-program-in-gcc-with-sdl-image/27449/1 "2020-04-07T10:49:09Z")

</div>

Program’s “test.cpp” code:  
#include \<SDL/SDL.h\>  
#include \<SDL2/SDL\_image.h\>

using namespace std;

SDL\_Window \*win = NULL;  
SDL\_Renderer \*ren = NULL;  
SDL\_Surface \*screen = NULL;  
bool init(){  
if( SDL\_Init( SDL\_INIT\_VIDEO ) \< 0 )  
{  
std::cout\<\<"SDL could not initialize! SDL\_Error: "\<\< SDL\_GetError()\<\< endl;  
return 1;  
}  
else  
{  
//Create window  
win = SDL\_CreateWindow( “risovach”, SDL\_WINDOWPOS\_UNDEFINED, SDL\_WINDOWPOS\_UNDEFINED, 500, 500, SDL\_WINDOW\_SHOWN );  
if( win == NULL )  
{  
std::cout\<\< "Window could not be created! SDL\_Error: "\<\< SDL\_GetError()\<\< endl;  
return 1;  
}  
else  
{  
ren = SDL\_CreateRenderer( win, -1, SDL\_RENDERER\_ACCELERATED );  
}  
screen = SDL\_GetWindowSurface(win);  
}  
return 0;  
}

int main()  
{  
init();  
SDL\_Surface \*image = IMG\_Load("/home/goodgame/Desktop/anime.jpeg");  
SDL\_BlitSurface( image, NULL, screen, NULL );  
SDL\_Delay(2000);  
return 0;  
}

Command in Linux terminal:  
g++ -o test test.cpp -lSDL2 -lSDL2\_image

Error text:  
In file included from test.cpp:3:  
/usr/include/SDL2/SDL\_image.h:27:10: fatal error: SDL.h: Нет такого файла или каталога (From russian it mean something about “don’t have this file”)  
#include “SDL.h”  
^ ~~~~~~

What I should do?

---

<div class="post-metadata">

**Author:** ![gupr](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@gupr](https://discourse.libsdl.org/u/gupr)\
**Post date:** [April 7, 2020, 10:51am UTC](https://discourse.libsdl.org/t/cant-compile-program-in-gcc-with-sdl-image/27449/2 "2020-04-07T10:51:02Z")

</div>

Sorry if I have some mistakes in text, english isn’t my native language.

---

<div class="post-metadata">

**Author:** ![ericb](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/f19dbf/32.png) [@ericb](https://discourse.libsdl.org/u/ericb)\
**Post date:** [April 11, 2020, 2:48pm UTC](https://discourse.libsdl.org/t/cant-compile-program-in-gcc-with-sdl-image/27449/3 "2020-04-11T14:48:20Z")

</div>

Sorry, I don’t read russian, but can you try 🙂

```auto
g++ -o test test.cpp -lSDL2_image `sdl2-config --cflags --libs` 

```

And if it does not work, retry doing:  
LANG=C g++ -o test test.cpp -lSDL2\_image `sdl2-config --cflags --libs`

Maybe we could understand the error message then 🙂
