sqlitebiicode

Use SQLite with biicode


So far I have been able to succesfully use boost, cereal and gtest using biicode but I am having troubles with sqlite. I am trying to use it doing the following:

#include <sqlite3.h>

So I edited my biicode.conf to include those lines, including the alising for the header:

[requirements]
    sqlite/sqlite:9
[includes]
    sqlite.h: sqlite/sqlite/sqlite3/sqlite3.h

But when I try to call bii cpp:build it does the following

WARN: Removing unused reference to "sqlite/sqlite: 9" from myuser/test "requirements"

Then I ended up with the expected:

database_impl.cpp:(.text+0x516): undefined reference to `sqlite3_exec'

Surprisingly, the compilation succedd even though sqlite3.h is obviously not included but that's maybe because the call to sqlite is from a template function.

I have looked at the example but CMakeList.txt does not seem to add any additional includes directories. For example for boost I had to add:

SET(Boost_USE_STATIC_LIBS OFF)
bii_find_boost(COMPONENTS chrono system filesystem log thread REQUIRED)

target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS})
target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES})

But the two examples I found here and here don't seem to add anything to the includes directories, not even a link folder. I suppose sqlite has to be compiled with your sources so how do I make biicode add those files to my projects automatically ?


Solution

  • There're several problems. You just wrote in [includes] section sqlite.h instead of sqlite3.h and you should only write the prefix, sqlite/sqlite/sqlite3, later instead of the full dependency name.

    Then, you can solve it so:

    [requirements]
        sqlite/sqlite: 9
    [includes]
        sqlite3.h: sqlite/sqlite/sqlite3
    

    Or, you could try the SQLite version uploaded into fenix user:

    [requirements]
        fenix/sqlite: 0
    [includes]
        sqlite3.h: fenix/sqlite
    

    Don't worry about a "WARN" message that says biicode is ignoring sqlite3.c file because it's harcoded into the block CMakeLists.txt to catch this file ;)

    Note: you should write your external #includes's with double quotes instead of <>, because the last ones are referred to system headers and biicode could be using some system deps and you don't realize it.