Installation

The ObjectBox C / C ++ database is setup within minutes. Get the library and the generator and start developing high performance data applications.

ObjectBox library

There are a couple of ways to get the ObjectBox library (we recommend CMake 3.14 or newer):

CMake 3.14+
CMake (v3.11+)
download.sh
GitHub
CMake 3.14+

Use CMake's FetchContent to get ObjectBox headers and library ready to use in your project:

CMakeLists.txt
include(FetchContent)
FetchContent_Declare(
objectbox
GIT_REPOSITORY https://github.com/objectbox/objectbox-c.git
GIT_TAG v0.14.0
)
FetchContent_MakeAvailable(objectbox)
add_executable(myapp main.cpp)
target_link_libraries(myapp objectbox)

If you want to use an ObjectBox Sync variant of the library, change the list line to:

CMakeLists.txt
target_link_libraries(myapp objectbox-sync)
CMake (v3.11+)

Use CMake's FetchContent to get ObjectBox headers and library into your project like this:

CMakeLists.txt
include(FetchContent)
FetchContent_Declare(
objectbox
GIT_REPOSITORY https://github.com/objectbox/objectbox-c.git
GIT_TAG v0.14.0
)
FetchContent_GetProperties(objectbox)
if(NOT objectbox_POPULATED)
FetchContent_Populate(objectbox)
endif()
add_executable(myapp main.cpp)
target_link_libraries(myapp objectbox)

If you want to use an ObjectBox Sync variant of the library, change the list line to:

CMakeLists.txt
target_link_libraries(myapp objectbox-sync)
download.sh

Using the download.sh script (on Windows, use something like Git Bash to run it)

  • Get the repo's download.sh and run it in a terminal: bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/main/download.sh)

  • To get the ObjectBox Sync variant of the library, pass --sync to the previous command.

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 /usr/local/lib (macOS).

GitHub

Get the library for your platform from the latest GitHub release: https://github.com/objectbox/objectbox-c/releases/latest

Once you setup the headers and library like this, you can already start using the ObjectBox API! Here's a minimal example to verify your setup:

C++
C
C++
main.cpp
#include "objectbox.hpp"
int main() {
printf("Using ObjectBox version %s\n", obx_version_string());
}
C
main.c
#include "objectbox.h"
int main() {
printf("ObjectBox version %s\n", obx_version_string());
}

If you used CMake to setup your project you can already build and execute this program. Otherwise ensure your includes and the runtime shared library (libobjectbox.so, .dylib, .dll depending on the platform) are setup correctly for your compiler and linker environment.

ObjectBox Generator

Install the 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.

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).

Try running objectbox-generator -help to verify the installation and see the options.

FlatBuffers (optional)

If you prefer to work with C++ classes, we recommend using ObjectBox Generator. It's a higher level abstraction which takes care of FlatBuffers so you don't have to.

You can still use FlatBuffers directly, e.g. for zero-copy data access which can be even faster.

ObjectBox uses the high-performance binary representation "FlatBuffers" to achieve cross-platform compatibility of the stored data. Google provides FlatBuffers implementation for various languages including C++.

C++
C
C++

The ObjectBox shared library already includes FlatBuffers symbols so no additional linking should be necessary. For headers, there are two options:

  1. If you're using CMake and the FetchContent command like described above, you are already set up to work with FlatBuffers APIs. The FlatBuffers headers are already part of the objectbox library interface include directories.

  2. Get the FlatBuffers headers, e.g. copy them into your source/include path.

C

Get flatcc library and headers. You can link your program to the to the static runtime library.

CMake example (check the link above for the latest version):

FetchContent_Declare(
flatcc
GIT_REPOSITORY https://github.com/dvidelabs/flatcc.git
GIT_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)