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.

Principle:CARLA simulator Carla Build Prerequisites

From Leeroopedia
Knowledge Sources
Domains Build_System, Development
Last Updated 2026-02-15 00:00 GMT

Overview

Automated dependency resolution ensures that all system-level packages and development libraries required by the CARLA C++/Python build environment are correctly installed before compilation begins.

Description

Building CARLA from source requires a substantial set of system prerequisites spanning C++ compilers, build tools, graphics libraries, and Python development packages. The CARLA project provides an automated installation script (Util/SetupUtils/InstallPrerequisites.sh) that detects the host operating system and installs all necessary dependencies using the appropriate package manager.

The required packages fall into several categories:

  • Build toolchain: build-essential, clang, lld (linker)
  • Build system: cmake (>= 3.28), ninja-build
  • Graphics/rendering: Vulkan SDK, libvulkan-dev, GPU drivers
  • Python development: python3-dev, python3-pip, python3-venv
  • Networking/serialization: libprotobuf-dev, protobuf-compiler
  • Compression/utility: zlib1g-dev, libtiff-dev, libjpeg-dev, libpng-dev

Usage

This principle applies when:

  • Setting up a new build machine for CARLA development
  • Provisioning CI/CD build agents
  • Troubleshooting build failures that may stem from missing system libraries
  • Upgrading to a new CARLA version that may require updated dependencies

Theoretical Basis

Complex C++/Python projects like CARLA depend on a deep stack of system libraries that must be present at compile time and, in some cases, at runtime. Automated dependency resolution addresses several challenges inherent to this complexity:

Dependency graph completeness: CARLA's build pipeline compiles native C++ code (LibCarla), links against system libraries (Vulkan, Boost, protobuf), and builds Python extension modules (via Boost.Python). Each of these stages has its own set of dependencies, and missing a single library header or shared object will cause a build failure -- often with cryptic error messages. The prerequisites script encodes the complete dependency graph, ensuring nothing is overlooked.

Platform abstraction: Different Linux distributions use different package managers (apt, dnf, pacman) and may name the same library differently. The installation script abstracts these differences by detecting the distribution and translating the logical dependency list into platform-specific package names.

Version constraints: Certain dependencies have minimum version requirements. CMake >= 3.28 is required because CARLA's CMakeLists.txt uses features introduced in that version (such as improved preset support and generator expressions). The script can install from alternative sources (PPAs, SDKs) when the distribution's default package version is too old.

Idempotency: The script is designed to be safe to run multiple times. Package managers inherently handle the case where a package is already installed, but the script also avoids redundant downloads of external SDKs by checking for the presence of marker files or directories.

Privilege escalation: System package installation requires root privileges. The script is invoked via sudo -E to preserve the caller's environment variables (particularly PATH and any custom Python paths) while gaining the necessary permissions. The -x flag enables bash tracing for debugging visibility.

Practical Guide

Step 1: Navigate to the CARLA repository root

cd CarlaUE5

Step 2: Run the prerequisites installation script

sudo -E bash -x Util/SetupUtils/InstallPrerequisites.sh --python-path=python3

The --python-path=python3 flag specifies which Python interpreter to use for detecting Python-related dependency paths.

Step 3: Verify critical dependencies

After the script completes, verify that the key tools are available:

cmake --version    # Should be >= 3.28
ninja --version    # Should be installed
python3 --version  # Should be 3.8+
vulkaninfo         # Should report Vulkan instance info

Step 4: Resolve any remaining issues

If the script reports errors for your distribution, you may need to manually install specific packages. Consult Docs/build_linux_ue5.md for distribution-specific guidance.

Related Pages

Implemented By

Page Connections

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