Skip to main content

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

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

CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(myapp)
set(CMAKE_CXX_STANDARD 11) # C++11 or higher

include(FetchContent)
FetchContent_Declare(
objectbox
GIT_REPOSITORY https://github.com/objectbox/objectbox-c.git
GIT_TAG v4.1.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 target_link_libraries to:

target_link_libraries(myapp objectbox-sync)
info

Supported Platforms:
Linux (x86_64, aarch64, armv7hf, armv6hf), macOS (x64,arm64), Windows (x64,x86)

On Windows you might have to install the latest Microsoft Visual C++ Redistributable package (X64) to use the ObjectBox DLL.

Support for other platforms and architectures on request (i.e. QNX, armv6)

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:

main.cpp
#define OBX_CPP_FILE // Put this define in one file only before including
#include "objectbox.hpp"

int main() {
printf("Using ObjectBox version %s\n", obx_version_string());
return 0;
}
info

#define OBX_CPP_FILE is not strictly required in this minimal example. However, when starting with the real C++ API, it is required to have exactly one .cpp file that defines OBX_CPP_FILE right before the inclusion of the "objectbox.hpp" header.

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

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

Using the ObjectBox Generator with CMake is straightforward (after the installation via FetchContent above):

# Downloads automatically if not found on system per default)
find_package(ObjectBoxGenerator 4.0.0 REQUIRED)

# generate C++ files from tasklist.fbs and compile/link with target
add_obx_schema(
TARGET myapp
SCHEMA_FILES tasklist.fbs
INSOURCE # Opt-in: Generate in source directory
CXX_STANDARD 11 # Defaults to C++14 otherwise
)

For more details, please refer to the Generator documentation page.

FlatBuffers

ObjectBox uses FlatBuffers to represent objects at lower levels. It is a highly efficient binary representation that works across platforms. For advanced usage, you can opt to work with FlatBuffers directly.

tip

If you are using the recommended CMake's FetchContent ObjectBox setup, there's no FlatBuffers setup required. You can skip this section.