title: Makefile, linking a library
body: <p>I have 4 source files and 5 header files and I use the following libraries: </p>
  
  <ul>
  <li>SDL</li>
  <li>SDL_gfx </li>
  <li>SDLmain</li>
  <li>SDL_ttf</li>
  </ul>
  
  <p>But when I try out my makefile I get the following error: </p>
  
  <pre><code>/usr/bin/ld: cannot find -lSDL_gfx.
  </code></pre>
  
  <p>This is the make file I have so far: </p>
  
  <p><em>The first rule links all the object files together and the other ones are responsible for creating the object files</em></p>
  
  <pre><code>CC=gcc
  CFLAGS=-I -c -fmessage-length=0 -D_SDL_main_h -lSDL -lSDL_ttf -lSDL_gfx.
  DEPS = game.h field.h cell.h allocate_field.h GUI.h
  OBJ = game.o field.o allocate_field.o GUI.o 
  OUTPUT = game
  
  all: $(OBJ)
      @echo Programma aanmaken
      gcc -o $@ $^ $(CFLAGS)
  
  
  game.o : game.c field.h GUI.h
      @echo Bezig met game.o te compileren
      $(CC) -c -o game.o game.c
  
  field.o : field.c allocate_field.h cell.h
      @echo Bezig met field.o te compileren
      $(CC) -c -o field.o field.c
  
  allocate_field.o : cell.h
      @echo Bezig met allocate_field.o te compileren
      $(CC) -c -o allocate_field.o allocate_field.c
  
  GUI.o : field.h cell.h 
      @echo Bezig met GUI.o te compileren
      $(CC) -L/home/usr/lib/x86_64-linux-gnu -lSDL -lSDL_ttf -lSDL_gfx -c -o GUI.o GUI.c
  
  
  .PHONY : clean  
  clean:
      @echo Cleaning... Object files verwijderen  
      rm -f *.o
      rm -f $(OUTPUT)
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>The directory my libraries are in is /usr/lib/x86_64-linux-gnu.</p>
  
  <p>I tried the echo command with the directory I mentioned here above, but I cant get it to work</p>
  
  <p><strong>EDIT EDIT</strong></p>
  
  <p>I think you meant the dot in the CFLAGS line. I removed it and then I got this error: </p>
  
  <pre><code>undefined reference to `IMG_Load' which is one the functions of the SDL_image library
  </code></pre>
  
  <p>Then I also added -lSDL_image and now it works.</p>