title: Linking error: Undefined reference to functions that're defined in a separate file?
body: <p>I'm probably forgetting something obvious that'll solve this.  While there's other questions on SO with the same issue, none of the solutions have been applicable to my situation.</p>
  
  <p>I have a main file, sim.c, a header file net.h, a header file friends.h, and a file with the functions, net.c.  I have a makefile, which I created with gmakemake > Makefile, and its contents are very basic.</p>
  
  <p>Header.mak (makefile template):</p>
  
  <pre><code>CFLAGS = -Wall -Wextra -pedantic -std=c99 -ggdb
  LFLAGS = -ggdb
  LDFLAGS =
  </code></pre>
  
  <p>Makefile relevant contents:</p>
  
  <pre><code>CPP_FILES =
  C_FILES =       net.c sim.c
  PS_FILES =
  S_FILES =
  H_FILES =       net.h friends.h
  SOURCEFILES =   $(H_FILES) $(CPP_FILES) $(C_FILES) $(S_FILES)
  .PRECIOUS:      $(SOURCEFILES)
  OBJFILES =
  
  #
  # Main targets
  #
  
  all:    net sim
  
  net:       net.o $(OBJFILES)
          $(CC) $(CFLAGS) -o net net.o $(OBJFILES) $(CLIBFLAGS)
  
  sim:       sim.o $(OBJFILES)
          $(CC) $(CFLAGS) -o sim sim.o $(OBJFILES) $(CLIBFLAGS)
  
  #
  # Dependencies
  #
  
  net.o:     net.h
  sim.o:     net.h
  </code></pre>
  
  <p>My sim.c file contains:</p>
  
  <pre><code>#include "net.h"
  #include "friends.h"
  </code></pre>
  
  <p>My header file contains the functions in net.c and defines them all as stubs.  I copied and pasted them to create the function headers, so there shouldn't be any typos.</p>
  
  <p>My net.c file contains:</p>
  
  <pre><code>#include "net.h"
  </code></pre>
  
  <p>Yet any time a function in sim.c tries to call a function in net.c, it errors on that line with:</p>
  
  <pre><code>"undefined reference to `function_name`".
  </code></pre>
  
  <p>How can I make sim.c able to access the functions in net.c?</p>