title: Undefined references in makefile
body: <p>Ok, ive read about 10 tutorials, but i keep getting errors all the time, i have 5 files, main.cpp
  class.cpp, class.h and functions.cpp and functions.h. All of those use functions from different objects meaning that functions in functions.cpp uses objects from classes.cpp.</p>
  
  <p>My makefile looks as follows</p>
  
  <pre><code>CC = g++ -O2 -I./sdl/include -L.
  LIBS = -lm -lSDL -lpthread -ldl
  SRC = main.cpp
  SDLF = SDLfunctions.cpp
  CLASS = classes.cpp
  CLASSH = classes.h
  SDLFH = SDLfunctions.h
  
  all: main
  
  main: SDLfunctions.o Classes.o $(SRC)
      $(CC) -o $@ $(SRC) $(LIBS)
  
  SDLfunctions.o: $(SDLFH) $(SDLF) $(CLASS) $(CLASSH)
      $(CC) -o $@ $(SDLF) $(LIBS)
  
  Classes.o: $(CLASS) $(CLASSH) $(SDLF) $(SDLFH)
      $(CC) -o $@ $(CLASS) $(LIBS) 
  </code></pre>
  
  <p>I keeps telling me that it has undefined references. What am i missing?</p>
  
  <p>What makefile outputs</p>
  
  <pre><code>/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../crt1.o: In function `_start':
  (.text+0x18): undefined reference to `main'
  /tmp/ccJG6yQA.o: In function `DrawEnemies(SDL_Surface*)':
  SDLfunctions.cpp:(.text+0x3a7): undefined reference to `Enemy::sprite'
  /tmp/ccJG6yQA.o: In function `rysujpociski(int, SDL_Surface*, SDL_Surface*, 
  std::vector&lt;AllyBullet, std::allocator&lt;AllyBullet&gt; &gt;&amp;, double)':
  SDLfunctions.cpp:(.text+0x141f): undefined reference to `AllyBullet::sprite'
  /tmp/ccJG6yQA.o: In function `global constructors keyed to width':
  SDLfunctions.cpp:(.text+0x14a7): undefined reference to `Enemy::Enemy()'
  collect2: ld returned 1 exit status
  make: *** [SDLfunctions.o] Error 1
  </code></pre>
  
  <p>The files compile great when i had them in Visual C++, so it has to be my makefile.</p>