2

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?

Jackzz
  • 1,417
  • 4
  • 24
  • 53
  • Did you tried to create something in sqlite manually? Maybe your linking to sqlite broke in your executable – Superlokkus Oct 13 '16 at 12:01
  • @Superlokkus: No I didnt create anything manually. – Jackzz Oct 19 '16 at 06:40
  • You'd misunderstood me: Please try to create something manually with sqlite, to make sure sqlite is actual working, and to exclude the scenario that ODB did nothing wrong, because you can't use sqlite anyway. – Superlokkus Oct 19 '16 at 10:03
  • @Superlokkus: When I add the files generated by the odb compiler with the executable rather than the library, everything goes fine. So SQLITE is working, rght? – Jackzz Oct 19 '16 at 10:14
  • No, try for example to open a file database with, I'm not sure; `sqlite3_open` – Superlokkus Oct 19 '16 at 11:18

1 Answers1

0

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:

Marco Craveiro
  • 735
  • 9
  • 13