title: undefined reference to <function name>
body: <p>I have this simple test file:</p>
  
  <pre><code>#include "stack.h"
  
  int main()
  {
    Stack* stck = init_stack();
  
    return 0;
  }
  </code></pre>
  
  <p>and <code>stack.h</code> is defined as follows:</p>
  
  <pre><code>#ifndef STACK_H
  #define STACK_H
  
  #define EMPTY_STACK -1
  typedef struct stack
  {
    char ch;
    struct stack* prev;
  } Stack;
  
  extern Stack* init_stack();
  
  extern char pop(Stack*);
  
  extern void push(Stack*, char);
  
  #endif
  </code></pre>
  
  <p>These two files are in the same directory. But when I do <code>gcc ..</code> to build it, I keep getting the error below:</p>
  
  <pre><code>$ ls
  stack.c  stack.h  teststack.c
  $ gcc -o testit teststack.c 
  /tmp/ccdUD3B7.o: In function `main':
  teststack.c:(.text+0xe): undefined reference to `init_stack'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>Could anyone tell me what I did wrong here?</p>
  
  <p>Thanks,</p>