Static Class Variables in Dynamic Library and Main Program [duplicate]
This question already has an answer here: Main Program and Shared Library initializes same static variable in __static_initialization_and_destruction_0 1 answer I am working on a project that has a class 'A' that contains a static stl container class. This class is included in both my main program and a .so file. The class uses the default(implicit, not declared) constructor/destructor. The main program loads the .so file using dlopen() and in its destructor, calls dlclose(). The program crashes after main exits when glibc calls the destructor for the static class member variable. The problem