Skip to main content

Building from Source

Prerequisites​

  • C++ compiler with C++20 support (GCC 10+, Clang 12+, MSVC 2019 16.11+)
  • CMake 3.15 or higher
  • Ninja build system (recommended)
  • Git
  • vcpkg package manager
Why C++20

flAPI links opentelemetry-cpp, whose abseil dependency exports a cxx_std_20 requirement, so the whole project builds at C++20. The bundled DuckDB is deliberately built at C++17 inside the same binary — CMake saves and restores CMAKE_CXX_STANDARD around it, because C++20 removed std::uncaught_exception(), which DuckDB still calls. Don't "simplify" that away.

On Ubuntu/Debian, you can install the basic requirements with:

sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build

Build Steps​

  1. Clone the repository with submodules:
git clone --recurse-submodules https://github.com/datazoode/flapi.git
cd flapi
  1. Initialize DuckDB submodule (pinned at v1.5.2, see CMakeLists.txt DUCKDB_EXPLICIT_VERSION):
git submodule update --init --recursive
cd duckdb
git checkout v1.5.2
cd ..
  1. Set up vcpkg:
# Bootstrap vcpkg if you haven't already
./vcpkg/bootstrap-vcpkg.sh

# Integrate vcpkg with your system
./vcpkg/vcpkg integrate install
  1. Build the project:
# Create build directory
mkdir -p build/release
cd build/release

# Configure with CMake
cmake ../.. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=../../vcpkg/scripts/buildsystems/vcpkg.cmake

# Build
ninja

# The binary will be available as 'flapi' in the current directory

Verifying the Build​

After building, you can verify the installation:

# Print the usage banner to confirm the binary runs
./flapi --help

# Validate a configuration without starting the server
./flapi --validate-config -c examples/flapi.yaml

# Optional: Move to system path for global access
sudo cp flapi /usr/local/bin/

You can also use the convenience make targets from the repository root:

make run-debug      # Runs build/debug/flapi with examples/flapi.yaml at --log-level debug
make run-release # Runs build/release/flapi with examples/flapi.yaml at --log-level info

Common Build Issues​

  1. Missing Dependencies: If you encounter missing dependency errors, make sure vcpkg is properly initialized and integrated.

  2. CMake Configuration Fails: Ensure you have the correct version of CMake and all required development tools installed.

  3. Build Memory Issues: If the build process fails due to memory constraints, you can limit parallel jobs:

ninja -j2  # Limit to 2 parallel jobs
  1. vcpkg Cache: To speed up future builds, vcpkg caches packages. The cache is typically located in ~/.cache/vcpkg.

Development Setup​

For development, you might want to build with debug symbols:

mkdir -p build/debug
cd build/debug
cmake ../.. -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE=../../vcpkg/scripts/buildsystems/vcpkg.cmake
ninja

The debug build will include additional information useful for development and debugging.

Next Steps​

🍪 Cookie Settings