Prerequisites
Before building ORB-SLAM3, ensure you have the following dependencies installed:Required Dependencies
- C++11 or C++0x Compiler: Required for thread and chrono functionalities
- CMake: Version 2.8 or higher
- OpenCV: Version 4.4 or higher (minimum 3.0)
- Eigen3: Version 3.1.0 or higher
- Pangolin: For visualization and user interface
- Boost: Required for serialization (
-lboost_serialization) - OpenSSL: Required for cryptographic functions (
-lcrypto)
Optional Dependencies
- RealSense SDK 2.0: For Intel RealSense camera support (D435i, T265)
- ROS: For ROS node examples (tested with ROS Melodic on Ubuntu 18.04)
- Python 2.7: Required for trajectory evaluation scripts
Build Process Overview
The build process consists of three main stages:Build Third-Party Libraries
Build DBoW2, g2o, and Sophus libraries included in the Thirdparty folder
Using the Build Script
The easiest way to build ORB-SLAM3 is using the providedbuild.sh script:
- Builds all third-party libraries (DBoW2, g2o, Sophus)
- Extracts the ORB vocabulary
- Builds the ORB-SLAM3 library
- Compiles all example executables
What Gets Built
After successful compilation:- Library:
lib/libORB_SLAM3.so- The main shared library - Executables: Various example programs in
Examples/directories:Examples/Monocular/- Monocular camera examplesExamples/Stereo/- Stereo camera examplesExamples/RGB-D/- RGB-D camera examplesExamples/Monocular-Inertial/- Monocular with IMU examplesExamples/Stereo-Inertial/- Stereo with IMU examplesExamples/RGB-D-Inertial/- RGB-D with IMU examples
Manual Build Process
If you prefer to build step-by-step or need to customize the build:Step 1: Build DBoW2
Step 2: Build g2o
Step 3: Build Sophus
Step 4: Extract Vocabulary
Step 5: Build ORB-SLAM3
CMake Configuration Options
ORB-SLAM3 uses several CMake configuration options:Build Type
Compiler Flags
The default Release build uses aggressive optimization:Optional Features
The build system automatically detects optional dependencies:- RealSense Support: Automatically enabled if
librealsense2is found - C++11/C++0x: Automatically detected and configured
Building for Specific Platforms
Ubuntu 16.04/18.04
Install dependencies:macOS
Install dependencies using Homebrew:Troubleshooting Common Build Errors
Error: OpenCV > 4.4 not found
Error: OpenCV > 4.4 not found
Solution: Install OpenCV 4.4 or higher. The build requires at least OpenCV 3.0, but 4.4+ is recommended.
Error: Eigen3 not found
Error: Eigen3 not found
Solution: Install Eigen3 development files.Verify installation:
Error: Pangolin not found
Error: Pangolin not found
Solution: Build and install Pangolin from source.
Error: undefined reference to boost::serialization
Error: undefined reference to boost::serialization
Solution: Install Boost serialization library.
Error: The compiler has no C++11 support
Error: The compiler has no C++11 support
Solution: Update your compiler to GCC 4.8+ or Clang 3.3+.
Build succeeds but vocabulary file missing
Build succeeds but vocabulary file missing
Solution: Extract the vocabulary file manually.This creates
ORBvoc.txt which is required for running ORB-SLAM3.Error: march=native not supported
Error: march=native not supported
Solution: Edit
CMakeLists.txt and change -march=native to -march=x86-64.Performance Optimization
Time Profiling
To enable execution time measurements, uncomment the following line ininclude/Config.h:
- Display time statistics in the terminal
- Save detailed timing to
ExecTimeMean.txt
Build Optimization Tips
Next Steps
After successfully building ORB-SLAM3:- Configure your camera parameters - Set up YAML configuration files
- Calibrate your camera - Perform camera and IMU calibration
- Run example datasets - Test with provided examples
- Integrate with ROS - Build and run ROS nodes