mardi 17 novembre 2020

How to prevent C++ symbols (reflection) in static library from being striped by Xcode when linking? (without using -force_load)

I am using C++ reflection in a static library to dynamically create classes. However when it's linking, lot of symbols are stripped because they are treated as dead symbols. The classes could not be created when the app is running.

I know that the link flag force_load could be used to load all the symbols in the static library. However this might cause other duplicated symbol problems, so force_load could not be used.

Here is what the reflection like:

// libA.a
// x.cpp
class X: public Y {
};
REGISTER_MACRO(X);
// the macro manages a name string to std::make_unique<Y> map, 
// the type in make_unique is the super class Y

Any suggestion for this? e.g., is there any link flags to prevent stripping single symbol?





Aucun commentaire:

Enregistrer un commentaire