title: C: undefined reference to a variable when using extern
body: <p>I try to declare a global variable <code>config</code>:</p>
  
  <pre><code>//general.h
  
  struct config_t {
      int num;
  };
  
  extern struct config_t config;  //The global variable
  </code></pre>
  
  <p>Then I define config variable in <code>general.c</code>:</p>
  
  <pre><code>//general.c
  #include "general.h"
  
  struct config_t config = {
      num = 5;
  };
  </code></pre>
  
  <p>But, when I try to use the global variable 'config' in my main function, I get the error:</p>
  
  <pre><code>undefined reference to `config':
  </code></pre>
  
  <p>Main program:</p>
  
  <pre><code>//main.c
  #include "general.h"
  
  main() {
      config.num = 10;
  }
  </code></pre>
  
  <p>Why is it? </p>