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).
Ubuntu ​
sudo apt-get update
sudo apt-get install build-essential cmake git
Fedora ​
sudo dnf update
sudo dnf groupinstall "Development Tools" "Development Libraries"
sudo dnf install cmake git
Getting the Source ​
Download the source using git:
git clone https://github.com/mavlink/MAVSDK.git
cd MAVSDK
git submodule update --init --recursive
Building the MAVSDK library on Linux ​
Debug Build ​
For development, use the debug build:
cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild -S.
cmake --build build -j8
Release Build ​
For production use, build with optimizations enabled:
cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -S.
cmake --build build -j8
Installation ​
System-wide Installation ​
To install system-wide in /usr/local
:
sudo cmake --build build --target install
sudo ldconfig # Update linker cache
Local 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 install
Build 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 -j8
Build 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 toON
for dynamic libraries (.so),OFF
for static libraries (.a)SUPERBUILD
: Set toOFF
to use system dependencies instead of third party dependenciesCMAKE_PREFIX_PATH
: Set path where dependencies can be found ifSUPERBUILD
isOFF
BUILD_MAVSDK_SERVER
: Set toON
to build mavsdk_serverBUILD_WITHOUT_CURL
: Set toON
to build without CURL supportASAN
: Set toON
to enable address sanitizerUBSAN
: Set toON
to enable undefined behavior sanitizerLSAN
: Set toON
to enable leak sanitizerWERROR
: Set toON
to treat warnings as errors
Troubleshooting ​
Git Submodules Out of Date ​
If you encounter build issues, try updating the submodules:
git submodule update --recursive
Undefined References ​
If you get undefined reference errors after installation, update the linker cache:
sudo ldconfig
And try a clean build by wiping the build directory:
rm -r build