Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Ggml org Ggml C Cpp Build Environment

From Leeroopedia


Knowledge Sources
Domains Infrastructure, Build_System
Last Updated 2026-02-10 07:40 GMT

Overview

C11/C++17 build environment with CMake 3.14+, POSIX threads, and optional OpenMP for building the GGML tensor library and all backends.

Description

This environment provides the core build toolchain required to compile GGML from source. It uses CMake as the build system generator with support for multiple compilers (GCC, Clang, MSVC) across Linux, macOS, and Windows. The project requires C11 and C++17 standards. POSIX threads are mandatory for multi-threaded computation. OpenMP is optional but enabled by default for CPU backend parallelism.

Usage

Use this environment for any build of GGML from source, whether for the CPU-only backend or as the foundation for GPU-accelerated backends. All other backend environments (CUDA, Metal, Vulkan, SYCL, etc.) depend on this base environment being satisfied first.

System Requirements

Category Requirement Notes
OS Linux, macOS, or Windows CI-tested on Ubuntu latest, macOS latest, Windows latest
Compiler GCC, Clang, or MSVC ARM targets require Clang (MSVC not supported for ARM)
Build System CMake 3.14 to 3.28 3.18+ required for CUDA backend
Threading POSIX Threads Required; found via CMake Threads package

Dependencies

System Packages

  • `cmake` >= 3.14
  • `gcc` or `clang` or `msvc` (C11 + C++17 support)
  • `make` or `ninja` (build tool)
  • `git` (for version detection)

Optional System Packages

  • `openmp` (enabled by default for CPU parallelism)
  • `memkind` (for HBM memory allocation on supported hardware)

Credentials

No credentials are required for building GGML.

Quick Install

# Ubuntu/Debian
sudo apt-get install build-essential cmake git

# macOS (with Xcode Command Line Tools)
xcode-select --install
brew install cmake

# Build GGML (CPU only)
cmake -B build
cmake --build build --config Release

Code Evidence

CMake version and language standard requirements from `CMakeLists.txt:1-7`:

cmake_minimum_required(VERSION 3.14...3.28)
project("ggml" C CXX ASM)

set(GGML_VERSION_MAJOR 0)
set(GGML_VERSION_MINOR 9)
set(GGML_VERSION_PATCH 6)

C11 and C++17 standard enforcement from `CMakeLists.txt:275-278`:

set(CMAKE_C_STANDARD   11)
set(CMAKE_CXX_STANDARD 17)

Thread requirement from `CMakeLists.txt:281`:

find_package(Threads REQUIRED)

Default thread count from `include/ggml.h:232-233`:

#define GGML_DEFAULT_N_THREADS  4
#define GGML_DEFAULT_GRAPH_SIZE 2048

Common Errors

Error Message Cause Solution
`CMake Error: CMake 3.14 or higher is required` CMake version too old Upgrade CMake: `pip install cmake` or system package manager
`error: 'filesystem' is not a namespace-name` Compiler does not support C++17 Upgrade compiler to GCC >= 7, Clang >= 5, or MSVC >= 2017
`fatal error: 'thread' file not found` Missing POSIX thread support Install pthread development headers

Compatibility Notes

  • Linux: Full support with GCC and Clang. OpenMP parallelism available by default.
  • macOS: Uses Apple Accelerate framework for optimized BLAS operations. Clang from Xcode required.
  • Windows: MSVC and MinGW both supported. ARM builds require Clang, not MSVC.
  • WebAssembly: Supported via Emscripten with SIMD128 optimizations.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment