Hi,

I have the strangest issue, and I don't really know if it is the right place to post. Anyway, feel free to move it if I'm mistaken...

I'm using C++ singletons of the same class in 2 different dynamic libraries. Say a class A for instance. If I open the two libraries in my main program, using dlopen, then it seems that the two libraries does not share the same singleton. Meaning if I do A::getInstance in my first library, and A::getInstance in my second one, 2 objects of A are going to be created. All this on an Ubuntu.

It is fine, it's exactly the behavior I want (even if it doesn't sound as the "normal" behavior). My problem is that on MacOSX (Leopard), using the same code and compilation command (I'm using cMake on both platforms), it is not the same : the singleton is shared between my 2 libraries, and is created only once.
The issue seems to be whether a static member is shared between libraries or not. Maybe it is caused by a gcc default option different on MacOSX and Ubuntu, oy maybe I misunderstood everything... I'm completely lost, and 2 hours of google have been unsuccessfull (I'm struggling to find the right words to describe this issue...)

Anyway, some help on the matter would be more than welcome

Thanks !