Building from Source¶
This guide covers the build system, compiler configurations, and compilation steps for building MemoraDB across supported platforms.
Build System Architecture¶
MemoraDB uses CMake 3.20+ as its meta-build system. The build configuration is defined in the root CMakeLists.txt and manages:
- Language Standard: ISO C++17 (
set(CMAKE_CXX_STANDARD 17)). - Automatic Dependency Fetching: Uses
FetchContentto download Microsoft ONNX Runtime 1.22.0. - Automatic Model Acquisition: Downloads
model.onnxandvocab.txtfrom Hugging Face (sentence-transformers/all-MiniLM-L6-v2) if not already present. - Compilation Targets:
memora(Static Library): Compiles all DBMS subsystems (catalog, storage, index, temporal, vector, query, lexer, parser, engine).memora_cli(Executable): Compiles the terminal REPL and links againstmemora(output name set tomemora).memora_tests(Test Executable): Optional test target built when-DMEMORA_BUILD_TESTS=ON.- Post-Build Automation: Copies dynamic libraries (
onnxruntime.dll) and model assets to the output directory adjacent to the binary.
Prerequisites¶
Before building, ensure you have: * A modern C++17 compiler: * Windows: Visual Studio 2022 (MSVC) or MinGW-w64 (GCC 9+) * Linux: GCC 9+ or Clang 10+ * macOS: Apple Clang 12+ (Xcode Command Line Tools) * CMake 3.20+ * Git * (Recommended) Ninja build tool for fast parallel builds
Step-by-Step Build Instructions¶
1. Clone the Repository¶
2. Windows¶
Open PowerShell or an x64 Native Tools Command Prompt for VS 2022:
3. Linux (Ubuntu / Debian / Fedora / Arch)¶
4. macOS (Apple Silicon or Intel)¶
# Install tools:
# brew install cmake ninja git
# Configure
cmake -G "Ninja" -S . -B build -DCMAKE_BUILD_TYPE=Release
# Compile
cmake --build build
# Run
./build/memora
Building and Running the Test Suite¶
MemoraDB features an automated developer test suite using GoogleTest and CTest. Testing is disabled by default to keep user builds lightweight.
To compile and execute the test suite:
# 1. Configure in a separate build directory with tests enabled
cmake -G "Ninja" -S . -B build-tests -DMEMORA_BUILD_TESTS=ON
# 2. Compile tests
cmake --build build-tests
# 3. Run all tests via CTest
ctest --test-dir build-tests --output-on-failure
# 4. Or run the test executable directly (supports GTest filters)
./build-tests/test/memora_tests --gtest_filter=TemporalTest.*
For more details on test fixtures, isolation, and adding new test suites, see the Testing Guide.
Offline / Air-Gapped Builds¶
If building in an environment without internet access:
- Pre-Download ONNX Runtime: Download the archive for your platform and set the CMake cache variable:
- Pre-Download Model Assets:
Download
model.onnxandvocab.txtfrom Hugging Face and place them intobuild/models/all-MiniLM-L6-v2/before compiling.