How can I compile a state machine into a dynamic link library (DLL)?
Invisible to the user, the library uses static data members to implement its own speed-optimized RTTI-mechanism for event<> and simple_state<> subtypes. Whenever such a subtype is defined in a header file and then included in multiple TUs, the linker later needs to eliminate the duplicate definitions of static data members. This usually works flawlessly as long as all these TUs are statically linked into the same binary. It is a lot more complex when DLLs are involved. The TuTest*.?pp files illustrate this: • TuTest.hpp: Instantiates a class template containing a static data member • TuTest.cpp: Includes TuTest.hpp and is compiled into a DLL • TuTestMain.cpp: Includes TuTest.hpp and is compiled into an executable Without any precautions (e.g. __declspec(dllexport) on MSVC compatible compilers), on most platforms both binaries (exe & dll) now contain their own instance of the static data member. Since the RTTI mechanism assumes that there is exactly one object of that member at runtime,