cereal
cereal copied to clipboard
What is the correct way of an explicit instantiation of a template class which is serialized with cereal?
I tried this:
template class MyNamespace::ClassA<MyNamespace::ClassB>;
But it leads to a lot of warnings, like this one:
ld: warning: direct access in cereal::detail::OutputBindingCreator<cereal::BinaryOutputArchive, MyNamespace::ClassA<MyNamespace::ClassB> >::OutputBindingCreator() to global weak symbol typeinfo for MyNamespace::ClassA<MyNamespace::ClassB> means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
How exactly do I need to do it in order to work with cereal?
Can you provide a minimal example of your class and its instantiation?
I have the same issue in an internal repository. Turning off visibility attribute on CEREAL_DLL_EXPORT in the line below appears to get rid of the linker's warning (hence this is coming from this library).
https://github.com/USCiLab/cereal/blob/8291f44e05d3e3ee3c4fc9e088231789b701e17e/include/cereal/details/static_object.hpp#L51
I attempted to create a minimum reproducible example (by means of an explicit template initiation), but am unable to. Will get back to you if I am successful.
您的邮件我已收到,谢谢合作!