title: SDL2 libSDL2_image.so: undefined reference to
body: <p>I'm using Kubuntu 18.04</p>
  
  <p>So i recently tried to use SDL2, i wanted to create a simple window showing a few pictures following a tutorial but i was unable to compile the example code.</p>
  
  <p>When i try to compile the code i get:</p>
  
  <pre><code>/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_ceilf'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_acosf'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_floorf'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_fabsf'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_LoadFile_RW'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_fmodf'
  /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libSDL2_image.so: undefined reference to `SDL_atan2f'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Command used: </p>
  
  <pre><code>gcc SDLProject.c -o SDLProject `sdl2-config --cflags --libs` -lSDL2_gfx -lSDL2_image
  </code></pre>
  
  <p>Command used to install SDL2 libs:</p>
  
  <pre><code>sudo apt install libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
  </code></pre>
  
  <p>Installed packages:</p>
  
  <pre><code>sudo apt list --installed | grep "sdl"
  
  WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
  
  libsdl2-2.0-0/bionic-updates,now 2.0.8+dfsg1-1ubuntu1.18.04.3 amd64 [installed]
  libsdl2-dev/bionic-updates,now 2.0.8+dfsg1-1ubuntu1.18.04.3 amd64 [installed]
  libsdl2-gfx-1.0-0/bionic,now 1.0.4+dfsg-1 amd64 [installed,automatic]
  libsdl2-gfx-dev/bionic,now 1.0.4+dfsg-1 amd64 [installed]
  libsdl2-image-2.0-0/bionic,now 2.0.3+dfsg1-1 amd64 [installed,automatic]
  libsdl2-image-dev/bionic,now 2.0.3+dfsg1-1 amd64 [installed]
  libsdl2-mixer-2.0-0/bionic,now 2.0.2+dfsg1-2 amd64 [installed,automatic]
  libsdl2-mixer-dev/bionic,now 2.0.2+dfsg1-2 amd64 [installed]
  libsdl2-ttf-2.0-0/bionic,now 2.0.14+dfsg1-2 amd64 [installed,automatic]
  libsdl2-ttf-dev/bionic,now 2.0.14+dfsg1-2 amd64 [installed]
  </code></pre>
  
  <p>I already tried deleting everything that is related to SDL / SDL2 and only reinstalling the ones the project uses (SDL2, gfx and image) and <strong>i found out that this error only happens when i try to inlude the SDL_image.h and I'm able to run other exmaple codes that does not use it.</strong></p>
  
  <p>I do not think that the error is related to the code itself but:</p>
  
  <pre><code>#include &lt;SDL2/SDL.h&gt;
  #include &lt;SDL2/SDL_image.h&gt;
  #include &lt;SDL2/SDL2_gfxPrimitives.h&gt;
  #include &lt;stdlib.h&gt;
  
  typedef enum Babu {
      VKiraly, VVezer, VBastya, VFuto, VHuszar, VGyalog,
      SKiraly, SVezer, SSastya, SFuto, SHuszar, SGyalog
  } Babu;
  
  enum { MERET = 52 };
  
  
  void babu_rajzol(SDL_Renderer *renderer, SDL_Texture *babuk, Babu melyik, int x, int y) {
  
      SDL_Rect src = { (melyik % 6) * 62 + 10, (melyik / 6) * 60 + 10, MERET, MERET };
      SDL_Rect dest = { x, y, MERET, MERET };
      SDL_RenderCopy(renderer, babuk, &amp;src, &amp;dest);
  }
  
  
  void sdl_init(int szeles, int magas, SDL_Window **pwindow, SDL_Renderer **prenderer) {
      if (SDL_Init(SDL_INIT_EVERYTHING) &lt; 0) {
          SDL_Log("Nem indithato az SDL: %s", SDL_GetError());
          exit(1);
      }
      SDL_Window *window = SDL_CreateWindow("SDL peldaprogram", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, szeles, magas, 0);
      if (window == NULL) {
          SDL_Log("Nem hozhato letre az ablak: %s", SDL_GetError());
          exit(1);
      }
      SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
      if (renderer == NULL) {
          SDL_Log("Nem hozhato letre a megjelenito: %s", SDL_GetError());
          exit(1);
      }
      SDL_RenderClear(renderer);
  
      *pwindow = window;
      *prenderer = renderer;
  }
  
  
  int main(int argc, char *argv[]) {
      SDL_Window *window;
      SDL_Renderer *renderer;
      sdl_init(320, 200, &amp;window, &amp;renderer);
  
      SDL_Texture *babuk = IMG_LoadTexture(renderer, "pieces.png");
      if (babuk == NULL) {
          SDL_Log("Nem nyithato meg a kepfajl: %s", IMG_GetError());
          exit(1);
      }
  
      boxRGBA(renderer, 0, 0, 319, 199, 0x90, 0xE0, 0x90, 0xFF);
      babu_rajzol(renderer, babuk, VKiraly, 82, 74);
      babu_rajzol(renderer, babuk, SGyalog, 82+MERET, 74);
      babu_rajzol(renderer, babuk, VHuszar, 82+2*MERET, 74);
      SDL_RenderPresent(renderer);
  
      SDL_DestroyTexture(babuk);
  
      SDL_Event event;
      while (SDL_WaitEvent(&amp;event) &amp;&amp; event.type != SDL_QUIT) {
      }
  
      SDL_Quit();
      return 0;
  }
  </code></pre>