snakster / cpp.react

C++React: A reactive programming library for C++11.
http://snakster.github.io/cpp.react/
Boost Software License 1.0
1.02k stars 128 forks source link

Issues when building as a dynamic library #11

Open kylefleming opened 9 years ago

kylefleming commented 9 years ago

When building CppReact into a dynamic library, the REACTIVE_DOMAIN() macro creates separate instances of the Engine and the InputManager for both the library and the library consumer.

This is because Instance() is defined in a header and declares static variables. However, given the nature of dynamic libraries, this actually creates 2 versions, 1 in the dynamic library's static address space and another in the static address space of application using the dynamic library. You can imagine how this might cause issues for someone using CppReact in a dynamic library.

For a discussion, see: http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux

(For reference, I'm on mac building with clang)