title: undefined reference when using makefile
body: <p>I have a given makefile, written by our Professor. 
  `</p>
  
  <pre><code>SHELL  = /bin/bash
  CC     = gcc
  CFLAGS = -Wall -W -std=c99 -pedantic
  LIBS   =
  
  # Rajouter le nom des executables apres '=', separes par un espace.
  # Si une ligne est pleine, rajouter '\' en fin de ligne et passer a la suivante.
  
  # To compile without bor-util.c file 
  EXECS = main
  
  # To compile with bor-util.c file 
  EXECSUTIL = 
  
  # To compile with bor-util.c &amp; bor-timer.c files
  EXECSTIMER = 
  
  
  .c.o :
      $(CC) -c $(CFLAGS) $*.c
  
  help ::
      @echo "Options du make : help all clean distclean"
  
  all :: $(EXECS) $(EXECSUTIL) $(EXECSTIMER)
  
  $(EXECS) : %: %.o 
      $(CC) -o $@ $@.o $(LIBS)
  
  $(EXECSUTIL) : %: %.o bor-util.o
      $(CC) -o $@ $@.o bor-util.o $(LIBS)
  
  $(EXECSTIMER) : %: %.o bor-util.o bor-timer.o
      $(CC) -o $@ $@.o bor-util.o bor-timer.o $(LIBS)
  
  clean ::
      \rm -f *.o core
  
  distclean :: clean
      \rm -f *% $(EXECS) $(EXECSUTIL) $(EXECSTIMER)
  `
  </code></pre>
  
  <p>All we have to do in this project, is to write our code in other file and use this makefile to compile as usual. 
  I've written a helloWorld function to test. I have 3 files 
  FUNCTIONS.C </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "functions.h"
  
  
      void printMsg(){
          printf("Hello World !");
      }
  </code></pre>
  
  <p>FUNCTIONS.H </p>
  
  <pre><code>#ifndef FUNCTIONS_H
  #define FUNCTIONS_H
  
  void printMsg();
  #endif /* FUNCTIONS_H */
  </code></pre>
  
  <p>And a MAIN.C file to test out everything </p>
  
  <pre><code>#include "functions.h"
  
  
  int main(){
  
      printMsg(); 
      return 0;
  }
  </code></pre>
  
  <p>and I've added <code>main</code> to the makefile. But I get this error message when I compile </p>
  
  <pre><code>gcc -o main main.o 
  main.o: In function `main':
  main.c:(.text+0xa): undefined reference to `printMsg'
  collect2: error: ld returned 1 exit status
  Makefile:32: recipe for target 'main' failed
  make: *** [main] Error 1
  </code></pre>
  
  <p>Does anyone know what's the solutions please ? Thank you </p>