[odb-users] Couldn't find method odb::database::id

Boris Kolpackov boris at codesynthesis.com
Fri Jan 28 03:10:00 EST 2022

Andy S <gatekeeper.mail at gmail.com> writes:

> If the ODB-related code is a static library which is then statically linked
> into the resulting executable, ODB fails with NULLs-initialized table
> (despite all the libodb-* libraries are shared-linked into the executable).

Yes, that explains it: in the dynamic mode nothing in your application
references the generated code for each concrete database. Rather, the
generated code registers itself in these function tables.

> If I only change the library definition to SHARED in my cmake config the
> result is: it works.

You can also fix this by linking the static library in the whole archive
mode (not sure what's the CMake's incantation, by the GCC options are
-Wl,--whole-archive <lib> -Wl,--no-whole-archive).

More information about the odb-users mailing list