How to reduce the implementation code of lots of wrapper classes?

If you drop inheritance in the wrapper, you might do something like the following to factorize all wrappers:

template <typename T>
class Wrapper
{
private:
   std::weak_ptr<T> m;
public:
   Wrapper() = delete;
   Wrapper(const std::weak_ptr<T> & w) : m(w) {}

   auto operator -> () /* const */
   {
       if (auto sp = m.lock())
       {
           return sp;
       }
       else
       {
            throw std::runtime_error("object is not loaded in the lib.");
       }
   }
};

The best you can do without resorting to macros (which also wouldn't help here, to fully resolve your problem we would need some kind of static reflection) is fix these repetitions:

if (auto sp = mC1.lock())
{
    sp->method1_C1();
}
else
{
     throw std::Exception("object C1 is not loaded in the lib.");
}

What I see you can easily reduce it to template function like this one:

template<class T, class R, class... Args>
R call_or_throw(const std::weak_ptr<T>& ptr, const std::string& error, R (T::*fun)(Args...), Args... args) {
    if (auto sp = ptr.lock()) 
    {
        return std::invoke(fun, *sp, args...);
    }
    else 
    {
        throw std::runtime_error(error.c_str());
    }
}

Than you can use it like that:

int method1_C1(int x)
{
    return call_or_throw(mC1, "object C1 is not loaded in the lib.", &C1::method1_C1, x);
}

void method2_C1(double y)
{
    return call_or_throw(mC1, "object C1 is not loaded in the lib.", &C1::method2_C1, y);
}

You can even make macro out of it


Using smart-pointers for tree/graph nodes is less than ideal. The tree node destructors destroy the smart-pointers to child nodes and those in turn call child node destructors resulting in recursion which may overflow the stack when the trees are deep or available stack size is small.

An alternative design is to have a tree class that manages the lifetime of its nodes and uses plain pointers, a-la std::map. And have a rule that removing a node invalidates pointers and references to the removed sub-tree.

Such a design is simple, robust and most efficient at run-time.