To start developing with ObjectBox you'll need to get the library and the generator executable.
The APIs come as a single header file for C and C++:
C++: include/objectbox.hpp (depends on objectbox.h)
Compile your code against it and use the runtime shared library (.so, .dylib, .dll depending on the platform) to link against.
There are a couple of ways to get the library:
If you're using CMake v3.11+ you can use CMake's FetchContent to get ObjectBox headers and library.
CMakeLists.txtinclude(FetchContent)FetchContent_Declare(objectboxGIT_REPOSITORY https://github.com/objectbox/objectbox-c.gitGIT_TAG v0.11.0)FetchContent_GetProperties(objectbox)if(NOT objectbox_POPULATED)FetchContent_Populate(objectbox)endif()add_executable(myapp main.cpp)target_link_libraries(myapp objectbox)
Additionally, if you're using C instead of C++ you also need to get the
flatcc library (see below for details). You can use FetchContent to do that as well:
FetchContent_Declare(flatccGIT_REPOSITORY https://github.com/dvidelabs/flatcc.gitGIT_TAG v0.6.0)FetchContent_GetProperties(flatcc)if(NOT flatcc_POPULATED)FetchContent_Populate(flatcc)endif()add_executable(c99app main.c)target_link_libraries(c99app objectbox flatccrt)
Using the download.sh script (on Windows, use something like Git Bash to run it)
Either clone the repo and run
... or get download.sh and run it in a terminal:
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/main/download.sh)
Details on the download.sh script:
Creates a "download" directory and a version dependent sub directory named like "libobjectbox-0.1-some-hex-hash".
Inside the version dependent sub directory, you will find the directories "include" and "lib"/
The "lib" directory contains the binary library.
Gives you an option to install the library to
/usr/lib (linux) or
Get the latest binary by browsing its Bintray repository (Conan repository format): https://bintray.com/objectbox/conan/objectbox-c%3Aobjectbox
Don't forget to include the library (so/dylib/dll) with your program when distributing/packaging for installer, otherwise your program users won't be able to run it.
Having the library in the same directory as your program binary should be enough for Windows. For other OSs you might need to ensure the installation library to the system directory (
/usr/local/lib) or one of the paths specified in
ObjectBox uses FlatBuffers high-performance binary representation to achieve cross-platform compatibility of the stored data. Google provides FlatBuffers implementation for various languages, including C++ and there's an independent implementation for C as well (third-party & semi-official - Google points to for C support). You can thus make your choice depending on the language you use.
For C: get flatcc library and headers. You can link your program to the to the static runtime library.
For C++: get flatbuffers headers. Objectbox shared library already includes flatbuffers symbols so no additional linking should be necessary. If you're using CMake's
FetchContent, you don't need to get the
flatbuffers headers separately - they're already part of the
objectbox library interface include directories.
ObjectBox Generator is a tool that will help you with during development of your application (and as opposed to the objectbox shared library, it's not supposed to be distributed with your app).
objectbox-generator executable by downloading the version for your OS from releases. If you want, add it to
$PATH for convenience. Alternatively, instead of downloading, you can build the generator yourself by cloning this repo and running
make. To build yourself, you need a recent Go version, CMake and a C++11 toolchain.