title: Multiple definition of a global variable
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2328671/constant-variables-not-working-in-header">constant variables not working in header</a>  </p>
  </blockquote>
  
  
  
  <p>In my header file which I use to create a shared object, I have the following:</p>
  
  <pre><code>#ifndef LIB_HECA_DEF_H_
  #define LIB_HECA_DEF_H_
  
  struct dsm_config {
      int auto_unmap;
      int enable_copy_on_access;
  };
  
  enum { NO_AUTO_UNMAP, AUTO_UNMAP } unmap_flag;
  enum { NO_ENABLE_COA, ENABLE_COA } coa_flag;
  
  const struct dsm_config DEFAULT_DSM_CONFIG = { AUTO_UNMAP, NO_ENABLE_COA };
  
  &lt;more code ...&gt;
  
  #endif
  </code></pre>
  
  <p>When I compile, I get the following error:</p>
  
  <pre><code>cc -g -Wall -pthread libheca.c dsm_init.c -DDEBUG    master.c   -o master
  /tmp/cciBnGer.o:(.rodata+0x0): multiple definition of `DEFAULT_DSM_CONFIG'
  /tmp/cckveWVO.o:(.rodata+0x0): first defined here
  collect2: ld returned 1 exit status
  make: *** [master] Error 1
  </code></pre>
  
  <p>Any ideas why?</p>