global variable with shared library

hi, I have a shared lib called In this “” I have one static global variable called “value”. I want to read this static global variable from another program that links to this “”. How can I do this? I have tried using extern value in my program to have access to this variable and it doesn’t work. Oh, and yes, I can call functions that is in the “” no problem.


Get rid of the “static” part?

it works now but I thought that if you declare global variable as static, then it just meant that that variable is only created once regardless of who calls it??? So why can’t it not work with static???

Nope, static is a directive to the compiler to not “export” the symbol. If a variable is defined as static, then object modules that have unresolved references to that variable name, will not be resolved during the link phase (dynamic or otherwise).


i guess I was confused by C++ term of public static variable…