title: Handling global variables in shared object
body: <p>I have some global variable defined in global.c file as below:</p>
  
  <pre><code>int globalvar;
  </code></pre>
  
  <p>I have a header file global.h that declares this variable as extern</p>
  
  <pre><code>extern int globalVar;
  </code></pre>
  
  <p>Now I have main.c that gets linked with compiled global.o (compiled from global.c) having code to open (using dlopen) a shared object sh.so that gets built from sh.c with access to globalVar, through global.h.
  Although, my executable has definition of globalVar (statically linked), when I load the dynamically linked library sh.so, it says undefined globalVar.
  How to handle this?</p>