Skip to content

Building from Sources

Edit page

To build from the sources, first you’ll need to fork and clone the repository from GitHub. Once you have a local copy, proceed with the building process.

Xapiand is written in C++20 and it has the following build requirements:

  • pkg-config
  • Ninja (optional)
  • A C++20 compiler: Clang >= 14 (Apple Clang >= 14) or GCC >= 13
  • CMake >= 3.14 (FetchContent is used heavily)
  • perl >= 5.6 (for a few building scripts)
  • Tcl >= 8.6 (to generate unicode/unicode-data.cc)

Xapiand makes use of quite a few libraries. Its search engine is a vendored fork of Xapian 2.0.0, built as part of the tree, and most of the remaining building blocks (MessagePack, the storage codecs, logging, the Asio-based reactor runtime, the Lua scripting engine via sol2, and more) are pulled in automatically at configure time through CMake’s FetchContent from the standalone Kronuz libraries, so a network connection is required the first time you configure. (Earlier releases embedded ChaiScript and a libev event loop; those are now Lua and the Asio reactor.)

The only external system dependencies you need to provide are:

  • zlib
  • libpthread (internally used by the Standard C++ thread library)
  • ICU >= 54.1 (optional)

To install the requirements under macOS you need:

Simply installing Xcode will not install all of the command line developer tools, the first time you must execute the following in Terminal, before trying to build:

Terminal window
# Install the command line developer tools:
xcode-select --install
Terminal window
brew install ninja
brew install pkg-config
brew install cmake
brew install icu

First download and untar the Xapiand official distribution or clone the repository from https://github.com/Kronuz/Xapiand.git

Terminal window
git clone -b master --single-branch --depth 1 \
"https://github.com/Kronuz/Xapiand.git"
Terminal window
cd Xapiand
mkdir build
cd build
Terminal window
cmake -GNinja ..
Terminal window
ninja
ninja check
ninja install

The build is configured with CMake options, toggled at configure time with -D<OPTION>=ON / -D<OPTION>=OFF. The defaults produce an optimized, clustered release; you rarely need to change them for a normal build.

OptionDefaultDescription
CMAKE_BUILD_TYPEReleaseBuild type (Release, RelWithDebInfo, Debug, …)
LTOONLink-Time Optimization
CLUSTERINGONRemote clustering
DATABASE_WALONDatabase write-ahead log (WAL)
DATA_STORAGEONData storage volumes
TRACEBACKSOFF (ON in Debug)Tracebacks in exceptions
ASSERTSOFF (ON in Debug)Runtime assertions
TRACKED_MEMOFFAllocator that attributes memory to call sites
BUILD_TESTSOFFBuild the test suite
ASANOFFAddressSanitizer (see Sanitizers)
UBSANOFFUndefinedBehaviorSanitizer
MSANOFFMemorySanitizer
TSANOFFThreadSanitizer

For example, a debug build with tracebacks and assertions:

Terminal window
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DTRACEBACKS=ON -DASSERTS=ON ..

When building sanitized versions of Xapiand, you’ll need to Configure the Build using the proper library:

For developing and debugging, generally you’d want to enable the Address Sanitizer, tracebacks in exceptions and debugging symbols, so you’ll have to Configure the Build using something like:

Terminal window
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTRACEBACKS=ON -DASSERTS=ON -DASAN=ON ..

UndefinedBehavior Sanitizer (ASAN + UBSAN)

Section titled “UndefinedBehavior Sanitizer (ASAN + UBSAN)”

For developing and debugging, generally you’d want to enable the Address Sanitizer and UndefinedBehavior Sanitizer, tracebacks in exceptions and debugging symbols, so you’ll have to Configure the Build using something like:

Terminal window
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTRACEBACKS=ON -DASSERTS=ON -DASAN=ON -DUBSAN=ON ..

For debugging memory issues, enable Memory Sanitizer and debugging symbols in release mode, so you’ll have to Configure the Build using something like:

Terminal window
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTRACEBACKS=ON -DASSERTS=ON -DMSAN=ON ..

For debugging multithread issues, enable Thread Sanitizer and debugging symbols in release mode, so you’ll have to Configure the Build using something like:

Terminal window
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTRACEBACKS=ON -DASSERTS=ON -DTSAN=ON ..