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

Сергей Никонов shprotello at mail.ru
Mon Apr 30 15:18:49 EDT 2018


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):

D:/odb-2.5.0-b.3/odb/bin/odb.exe --multi-database dynamic -d sqlite -d mysql -d pgsql -d common --std c++11 --default-pointer std::shared_ptr --export-symbol common:moduleB_EXPORT --extern-symbol common:moduleB_EXTERN --include-with-brackets  --generate-query --generate-session --hxx-prologue common:#include <export.h> --profile moduleA --fkeys-deferrable-mode mysql:not_deferrable B.h

I use odb-2.5.0-b.3 under MSVC 2015.

Is it possible to refer a persistent object from another library if a referencing persistent class is in another library?


More information about the odb-users mailing list