title: undefined reference to extern variable
body: <p>I'm trying to use an extern file pointer declared in a header file in two different .cpp files.  The following code is a reduced version of my project, but the logic is the same:</p>
  
  <p>file2.h:</p>
  
  <pre><code>extern FILE* output;
  void print_stuff();
  </code></pre>
  
  <p>file1.cpp:</p>
  
  <pre><code>#include "file2.h"
  int main() {
      output = fopen("hello.txt", "w");
      print_stuff();
  }
  </code></pre>
  
  <p>file2.cpp</p>
  
  <pre><code>void print_stuff() {
      fprintf(output, "hello\n");
  }
  </code></pre>
  
  <p>however, I'm getting undefined reference errors to the output filepointer in both cpp files.  Is there something I'm doing wrong?</p>