classes and static variables in shared libraries

Posted by abel on Stack Overflow See other posts from Stack Overflow or by abel
Published on 2010-03-24T04:44:38Z Indexed on 2010/03/24 4:53 UTC
Read the original article Hit count: 381

Filed under:
|
|

I am trying to write something in c++ with an architecture like:

App --> Core (.so) <-- Plugins (.so's)

for linux, mac and windows. The Core is implicitly linked to App and Plugins are explicitly linked with dlopen/LoadLibrary to App. The problem I have:

  • static variables in Core are duplicated at run-time -- Plugins and App have different copys of them.
  • at least on mac, when a Plugin returns a pointer to App, dynamic casting that pointer in App always result in NULL.

    Can anyone give me some explanations and instructions for different platforms please? I know this may seem lazy to ask them all here but I really cannot find a systematic answer to this question.

  • © Stack Overflow or respective owner

    Related posts about shared-libraries

    Related posts about c