Install Realm - C++ SDK Preview
On this page
The Realm C++ SDK enables client applications written in C++ to access data stored in realms and sync data with Atlas. This page details how to install Realm in your project and get started.
Requirements
Minimum C++ standard: C++17.
For development on macOS: Xcode 11.x or later.
For development on Windows: Microsoft Visual C++ (MSVC).
Otherwise, we recommend git and CMake.
Install
Usage
Include the Header
Make the Realm C++ SDK available in your code by including the
cpprealm/sdk.hpp
header in the translation unit where you want to use it:
Experimental Preview Features
New in version v0.2.0-preview.
The Realm C++ SDK Preview provides some features in a realm::experimental
namespace. When working with these experimental features, you must
import the experimental header.
And you can access features in the experimental namespace:
using namespace realm::experimental;
Build an Android App
The Realm C++ SDK Preview supports building Android apps. To build an Android app:
Add
<uses-permission android:name="android.permission.INTERNET" />
to yourAndroidManifest.xml
Add the subdirectory of the Realm C++ SDK to your native library's
CMakeLists.txt
and link it as a target library:set(CMAKE_CXX_STANDARD 17) add_subdirectory("realm-cpp") ... target_link_libraries( # Specifies the target library. myapplication # make sure to link the Realm C++ SDK. cpprealm ) Ensure that the git submodules are initialized inside of the
realm-cpp
folder before building.When instantiating the Realm or the Realm App, you must pass the
filesDir.path
as thepath
parameter in the respective constructor or realm open template.
For an example of how to use the Realm C++ SDK Preview in an Android app, refer to
the Android RealmExample App
in the realm-cpp
GitHub repository.
Specifically, refer to the MainActivity.kt
& native-lib.cpp
files
in the Android example app for code examples.