cereal icon indicating copy to clipboard operation
cereal copied to clipboard

What is the correct way of an explicit instantiation of a template class which is serialized with cereal?

Open FramusRock opened this issue 9 years ago • 3 comments

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?

FramusRock avatar Apr 23 '16 00:04 FramusRock

Can you provide a minimal example of your class and its instantiation?

AzothAmmo avatar Apr 25 '16 18:04 AzothAmmo

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.

jerin-thirdai avatar Aug 02 '22 06:08 jerin-thirdai

您的邮件我已收到,谢谢合作!

redchairman avatar Aug 02 '22 06:08 redchairman