Building MAVSDK on macOS ​
This guide explains how to build MAVSDK from source on macOS systems.
Requirements ​
The build requirements are:
- XCode Command Line Tools
- CMake
- Git
Install Build Tools ​
First install XCode Command line tools:
bash
xcode-select --installThen install Homebrew and use it to install CMake:
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install cmakeGetting the Source ​
Download the source using git:
bash
git clone https://github.com/mavlink/MAVSDK.git
cd MAVSDK
git submodule update --init --recursiveBuilding the MAVSDK library on macOS ​
Debug Build ​
For development, use the debug build:
bash
cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild -S.
cmake --build build -j8Release Build ​
For production use, build with optimizations enabled:
bash
cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -S.
cmake --build build -j8Installation ​
System-wide Installation ​
To install system-wide in /usr/local:
bash
sudo cmake --build build --target installLocal Installation ​
To install to a local folder, e.g. install:
bash
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -Bbuild -S.
cmake --build build --target installBuild for iOS ​
To build for real iOS devices on macOS:
bash
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MAVSDK_SERVER=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=tools/ios.toolchain.cmake -DPLATFORM=OS -Bbuild/ios -S.
cmake --build build/iosBuild for the iOS simulator on macOS:
bash
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MAVSDK_SERVER=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=tools/ios.toolchain.cmake -DPLATFORM=SIMULATOR64 -Bbuild/ios_simulator -S.Build Options ​
During the configure step you can set various flags using -DFLAG=Value:
CMAKE_BUILD_TYPE: Choose betweenDebugandReleasebuildCMAKE_INSTALL_PREFIX: Specify directory to install library artifactsBUILD_SHARED_LIBS: Set toONfor dynamic libraries (.dylib),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:
bash
git submodule update --recursive
