Link to home
Start Free TrialLog in
Avatar of gburson
gburson

asked on

Accessing global vars in an exe

I have an application on AIX that dynamically loads libraries at run-time (the executable is not linked to the libraries). Is it possible to access a global variable inside the executable, from the loaded library ? I tried declaring the global, then using "extern long glName;", and it compiles. But when I try to access it, my app crashes. P.S. my 'C' is quite rusty.

Thankyou,
Glen.
ASKER CERTIFIED SOLUTION
Avatar of rbr
rbr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gburson
gburson

ASKER

Thanks for the response. I am trying to test it. Can you advise me on how to export the function name. I have declared it like,

long * getAppInfo(void);

but when I check the exported functions, its not there (I check using 'nm' as I am running on AIX).

Thanks again,
Glen.
How do you export functions in a DLL under AIX?
You should be able to do the same with a global variable.
Avatar of gburson

ASKER

I had the same problem originally with the global (it wasn't exported). I referenced it in some of the code, and then it was exported. Not true with the function. I have called it in the code, explicitly named it in an export file, used the linker option to export all symbols, and its still not there !

I must be missing something ...

Ta,
Glen.