All in c code, I have one linux Gnome process which might load two libraries libA.so and libB.so.
libA needs to export a global variable int varA.
libB needs to access varA only if libA is present in the process.
How can I do that with the following constraint:
libB shall not link against libA. Also, It's possible that the process only loads libB and never touches libA. I don't control the process so no code should reside in the process source code. Only code in libB is allowed: it needs to check if libA is present in the process, and if that's the case, it needs to access varA. If libA is not present, libB should be aware that it can't access varA.
I was thinking of using g_module_open / g_module_symbol but I think it would force to load libA which I don't want to. How can I check programmatically in libB if libA is present and then access varA only in that case?