Building MAVSDK on Linux ​
This guide explains how to build MAVSDK from source on Linux systems.
Requirements ​
The build requirements are git, cmake, and a C++ compiler (GCC or Clang), and python.
Ubuntu ​
sudo apt-get update
sudo apt-get install build-essential cmake git python3 python3-pipFedora ​
sudo dnf update
sudo dnf groupinstall "Development Tools" "Development Libraries"
sudo dnf install cmake gitGetting the Source ​
Download the source using git:
git clone https://github.com/mavlink/MAVSDK.git
cd MAVSDK
git submodule update --init --recursiveBuilding the MAVSDK library on Linux ​
Debug Build ​
For development, use the debug build:
cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild -S.
cmake --build build -j8Release Build ​
For production use, build with optimizations enabled:
cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -S.
cmake --build build -j8Installation ​
System-wide Installation ​
To install system-wide in /usr/local:
sudo cmake --build build --target install
sudo ldconfig # Update linker cacheLocal Installation ​
To install to a custom location, e.g. install
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -Bbuild -S.
cmake --build build --target installBuild mavsdk_server binary on Linux ​
Language wrappers for MAVSDK other than C++ connect to the MAVSDK C++ core using gRPC. This gRPC server around the MAVSDK C++ library is called mavsdk_server (in the past it was referred to as the backend).
For more information about the architecture, also see how the auto-generation works.
In order to include the mavsdk_server in the build, add -DBUILD_MAVSDK_SERVER=ON:
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MAVSDK_SERVER=ON -Bbuild -S.
cmake --build build -j8Build Options ​
During the configure step you can set various flags using -DFLAG=Value:
CMAKE_BUILD_TYPE: Choose betweenDebug,Release, orRelWithDebInfo(optimizations and debug symbols)CMAKE_INSTALL_PREFIX: Specify directory to install library artifactsBUILD_SHARED_LIBS: Set toONfor dynamic libraries (.so),OFFfor static libraries (.a)SUPERBUILD: Set toOFFto use system dependencies instead of third party dependenciesCMAKE_PREFIX_PATH: Set path where dependencies can be found ifSUPERBUILDisOFFBUILD_MAVSDK_SERVER: Set toONto build mavsdk_serverBUILD_WITHOUT_CURL: Set toONto build without CURL supportASAN: Set toONto enable address sanitizerUBSAN: Set toONto enable undefined behavior sanitizerLSAN: Set toONto enable leak sanitizerWERROR: Set toONto treat warnings as errors
Troubleshooting ​
Git Submodules Out of Date ​
If you encounter build issues, try updating the submodules:
git submodule update --recursiveUndefined References ​
If you get undefined reference errors after installation, update the linker cache:
sudo ldconfigAnd try a clean build by wiping the build directory:
rm -r build
