Search Results

Search found 1 results on 1 pages for 'user3730495'.

Page 1/1 | 1 

  • Global variable in a Linux shared library

    - by user3730495
    Suppose we have the following setup under Linux, .so library named "libcnt.so" and 3 user space apps: "app1", "app2", "app3". This library does 1 simple thing, it says to the app (app dynamically links the library at runtime) by how many apps it is already linked. Apps should have access to link counter. My knowledge in C and Linux is somewhat limited in this aspect, but as I understand this information should be stored in a global variable inside the shared object. Something like: in libcnt.h extern int cnt_loads; in libcnt.c int cnt_loads = 0; // where each linking increments this counter or something... So, my question is how it should be declared and/or defined inside .so library to guaranty that multiple apps from user space get the same instance of that variable counter?

    Read the article

1