So I have a static library (MacOS, .a library). It's written in C++ and has static initializers in it's code like that:
//myclass.hpp
class MyClass {
...
static MyClass *defaultValue_;
static MyClass *newInitialDefaultValue();
...
}
...
//myclass.cpp
MyClass *MyClass::defaultValue_ = newInitialDefaultValue();
...
I'm linking my .dylib library against this .a lib. Unfortunately, when my .dylib file is loaded, no MyClass::newInitialDefaultValue()
is get called.
What could be the reasons and how to deal with this?
I've tried -all_load
and -force_load
linker flags with no luck.