ODB C++ - Unknown database schema error

860 Views Asked by At

In my Visual Studio solution, I have two different projects of which one is built as a static libraryand the other one as the executable. The ODB related code like creating the database and all are in the library. I linked this library to my executable. But when I debug the executable code, I get the error "unknown database schema" in the call create_schema().I am using SQLite as my database. What am I doing wrong?

1

There are 1 best solutions below

0
Marco Craveiro On

This problem is likely related to the issues described here and here, and which can be briefly summarised as follows: the C/C++ linker will ignore symbols from the static libraries if these symbols are not directly used in the main binary. ODB's implementation can fall into this trap, depending on how exactly you are instantiating the generated code. For GCC/Clang the solution is to use --whole-archive and for MSVC, on Visual Studio 2015 Update 2 and above, /WHOLEARCHIVE.

For more details see: