title: C Linux: Global variable located in shared library as singleton
body: <p>Is it possible to use global variable located in a shared library (.so) as a singleton if the library is used by more than one process?</p>
  
  <p>As example the initial value is 0, process 1 increments the var then proc2 increments the val and prints it.</p>
  
  <p>My experiments so far showed that the both process keep copies of the variable and if 1st increments it the second will still read 0. So the behavior is not like Windows DLLs...</p>
  
  <p>I read in one article here that if the global variable is <em>not</em> static (in the lib) and it's declared as extern in the lib header the var is unique for all the process. But so far I haven't been able to accomplish this - var is still copy for each process.</p>
  
  <p>Can someone please offer good explanation of this? And how to do it...</p>