[odb-users] Refer a persistent class from another persistent class, where both classes are implemented in different libraries

Boris Kolpackov boris at codesynthesis.com
Tue May 1 11:10:49 EDT 2018

Сергей Никонов <shprotello at mail.ru> writes:

> I've encountered a linking problem in the following situation:
> - persistent class 'A' is defined in 'moduleA' library
> - persistent class 'B' is defined in 'moduleB' library and refers to 'A'
> - both modules are built with dynamic multi-database support
> When I try to build a library with supporting database code for
> 'moduleB' I get the following linker error:
> error LNK2019: unresolved external symbol "public: static class std::shared_ptr<class A> __cdecl odb::access::object_traits_impl<class A,0>::find(class odb::database &,unsigned __int64 const &)" (...) referenced in function "protected: class std::shared_ptr<class A> __cdecl odb::database::find_<class A,0>(unsigned __int64 const &)" (...)
> ODB compiler options for B.h compiling are (not all):
> [...] --export-symbol common:moduleB_EXPORT

Provided that you have a similar export setup for the moduleA library
and that you link moduleA to moduleB, it should work.

Are you able to link moduleA to an executable that calls database::load<A>()
without unresolved symbols?


More information about the odb-users mailing list