Skip to content

Commit ffe6735

Browse files
authored
Merge pull request #2736 from mavlink/pr-docs-faq-and-link
Docs: fixup removed files, add notes about mavsdk_server to FAQ, fix links
2 parents 934341f + b7d68ee commit ffe6735

File tree

7 files changed

+610
-4
lines changed

7 files changed

+610
-4
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Cross-compilation with Dockcross and Android Builds
2+
3+
This guide explains how to build MAVSDK using dockcross for cross-compilation and how to build for Android.
4+
5+
## Building with Dockcross
6+
7+
[Dockcross](https://github.com/dockcross/dockcross) is a cross-compiling toolchain that can be used to build MAVSDK for various platforms.
8+
9+
### Requirements
10+
11+
- Docker installed and running
12+
- Git
13+
14+
### Getting Started with Dockcross
15+
16+
1. Clone the MAVSDK repository:
17+
```bash
18+
git clone https://github.com/mavlink/MAVSDK.git
19+
cd MAVSDK
20+
git submodule update --init --recursive
21+
```
22+
23+
2. Pull and run the appropriate dockcross image for your target platform
24+
3. Use the generated dockcross script to run your build commands
25+
26+
### Example: Cross-compiling for ARM
27+
28+
```bash
29+
# Get the dockcross script for ARM
30+
docker run --rm dockcross/linux-armv7 > ./dockcross-linux-armv7
31+
chmod +x ./dockcross-linux-armv7
32+
33+
# Use the script to run cmake and build
34+
./dockcross-linux-armv7 bash -c 'cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -S. && cmake --build build'
35+
```
36+
37+
## Building for Android
38+
39+
### Requirements
40+
41+
- Android NDK
42+
- CMake
43+
- Git
44+
- Java Development Kit (JDK)
45+
46+
### Setup Android NDK
47+
48+
1. Download and install [Android Studio](https://developer.android.com/studio)
49+
2. Install the NDK and CMake through Android Studio's SDK Manager:
50+
- Open Android Studio
51+
- Go to Tools -> SDK Manager
52+
- Select SDK Tools tab
53+
- Check "NDK (Side by side)" and "CMake"
54+
- Click Apply to download and install
55+
56+
### Building
57+
58+
1. Clone the repository:
59+
```bash
60+
git clone https://github.com/mavlink/MAVSDK.git
61+
cd MAVSDK
62+
git submodule update --init --recursive
63+
```
64+
65+
2. Set up environment variables:
66+
```bash
67+
export ANDROID_NDK_HOME=/path/to/android/ndk
68+
export ANDROID_CMAKE=/path/to/android/cmake
69+
```
70+
71+
3. Configure and build for your target Android architecture:
72+
```bash
73+
cmake \
74+
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
75+
-DANDROID_ABI=arm64-v8a \
76+
-DANDROID_PLATFORM=android-28 \
77+
-DCMAKE_BUILD_TYPE=Release \
78+
-Bbuild/android \
79+
-S.
80+
81+
cmake --build build/android
82+
```
83+
84+
### Android Build Options
85+
86+
- `ANDROID_ABI`: Specify the target architecture
87+
- `armeabi-v7a`: ARMv7 devices
88+
- `arm64-v8a`: ARMv8 64-bit devices
89+
- `x86`: x86 devices
90+
- `x86_64`: x86 64-bit devices
91+
92+
- `ANDROID_PLATFORM`: Minimum Android API level
93+
- Example: `android-28` for Android 9.0 (Pie)
94+
95+
### Additional Build Flags
96+
97+
The same build flags available for regular builds can be used:
98+
99+
- `BUILD_SHARED_LIBS`: Set to `ON` for shared libraries (.so)
100+
- `SUPERBUILD`: Set to `OFF` to use system dependencies
101+
- `BUILD_MAVSDK_SERVER`: Set to `ON` to build mavsdk_server
102+
- `BUILD_WITHOUT_CURL`: Set to `ON` to build without CURL support
103+
104+
## Troubleshooting
105+
106+
### Git Submodules Out of Date
107+
108+
If you encounter build issues, try updating the submodules:
109+
```bash
110+
git submodule update --recursive
111+
rm -rf build
112+
```
113+
114+
### Android NDK Version Issues
115+
116+
If you encounter issues with the NDK version:
117+
1. Make sure you're using a compatible NDK version
118+
2. Update your Android Studio and NDK to the latest stable versions
119+
3. Verify that `ANDROID_NDK_HOME` points to the correct NDK version

docs/en/cpp/guide/build_linux.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Building MAVSDK on Linux
2+
3+
This guide explains how to build MAVSDK from source on Linux systems.
4+
5+
## Requirements
6+
7+
The build requirements are git, cmake, and a C++ compiler (GCC or Clang), and python.
8+
9+
### Ubuntu
10+
```bash
11+
sudo apt-get update
12+
sudo apt-get install build-essential cmake git python3 python3-pip
13+
```
14+
15+
### Fedora
16+
```bash
17+
sudo dnf update
18+
sudo dnf groupinstall "Development Tools" "Development Libraries"
19+
sudo dnf install cmake git
20+
```
21+
22+
## Getting the Source
23+
24+
Download the source using git:
25+
```bash
26+
git clone https://github.com/mavlink/MAVSDK.git
27+
cd MAVSDK
28+
git submodule update --init --recursive
29+
```
30+
31+
## Building the MAVSDK library on Linux
32+
33+
### Debug Build
34+
35+
For development, use the debug build:
36+
```bash
37+
cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild -S.
38+
cmake --build build -j8
39+
```
40+
41+
### Release Build
42+
43+
For production use, build with optimizations enabled:
44+
```bash
45+
cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -S.
46+
cmake --build build -j8
47+
```
48+
49+
## Installation
50+
51+
### System-wide Installation
52+
53+
To install system-wide in `/usr/local`:
54+
```bash
55+
sudo cmake --build build --target install
56+
sudo ldconfig # Update linker cache
57+
```
58+
59+
### Local Installation
60+
61+
To install to a custom location, e.g. `install`
62+
63+
```bash
64+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -Bbuild -S.
65+
cmake --build build --target install
66+
```
67+
68+
## Build mavsdk_server binary on Linux
69+
70+
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).
71+
72+
For more information about the architecture, also see [how the auto-generation works](../contributing/autogen.md).
73+
74+
In order to include the mavsdk_server in the build, add `-DBUILD_MAVSDK_SERVER=ON`:
75+
76+
```bash
77+
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MAVSDK_SERVER=ON -Bbuild -S.
78+
cmake --build build -j8
79+
```
80+
81+
## Build Options
82+
83+
During the configure step you can set various flags using `-DFLAG=Value`:
84+
85+
- `CMAKE_BUILD_TYPE`: Choose between `Debug`, `Release`, or `RelWithDebInfo` (optimizations and debug symbols)
86+
- `CMAKE_INSTALL_PREFIX`: Specify directory to install library artifacts
87+
- `BUILD_SHARED_LIBS`: Set to `ON` for dynamic libraries (.so), `OFF` for static libraries (.a)
88+
- `SUPERBUILD`: Set to `OFF` to use system dependencies instead of third party dependencies (see [Building without Superbuild](#building-without-superbuild))
89+
- `CMAKE_PREFIX_PATH`: Set path where dependencies can be found if `SUPERBUILD` is `OFF`
90+
- `BUILD_MAVSDK_SERVER`: Set to `ON` to build mavsdk_server
91+
- `BUILD_WITHOUT_CURL`: Set to `ON` to build without CURL support
92+
- `ASAN`: Set to `ON` to enable address sanitizer
93+
- `UBSAN`: Set to `ON` to enable undefined behavior sanitizer
94+
- `LSAN`: Set to `ON` to enable leak sanitizer
95+
- `WERROR`: Set to `ON` to treat warnings as errors
96+
97+
### MAVLink Configuration
98+
99+
MAVSDK supports configuring the MAVLink dialect and repository:
100+
101+
- `MAVLINK_DIALECT`: MAVLink dialect to use (default: `ardupilotmega`)
102+
- `MAVLINK_XML_PATH`: Path to local MAVLink XML definition files. If not set, definitions are fetched automatically.
103+
- `MAVLINK_URL`: URL for the MAVLink repository (default: `https://github.com/mavlink/mavlink`)
104+
- `MAVLINK_HASH`: Git commit hash to use from the MAVLink repository
105+
106+
> **Note:** You can also load custom MAVLink message definitions at runtime using the [MavlinkDirect](../api_reference/classmavsdk_1_1_mavlink_direct.md) plugin, without needing to rebuild MAVSDK.
107+
108+
Examples:
109+
110+
```bash
111+
# Build with development dialect
112+
cmake -DCMAKE_BUILD_TYPE=Debug -DMAVLINK_DIALECT=development -Bbuild -S.
113+
114+
# Use a custom MAVLink repository fork
115+
cmake -DCMAKE_BUILD_TYPE=Debug \
116+
-DMAVLINK_URL=https://github.com/yourfork/mavlink \
117+
-DMAVLINK_HASH=abc123def456 \
118+
-Bbuild -S.
119+
120+
# Use local MAVLink XML files
121+
cmake -DCMAKE_BUILD_TYPE=Debug \
122+
-DMAVLINK_XML_PATH=/path/to/mavlink/message_definitions/v1.0 \
123+
-Bbuild -S.
124+
```
125+
126+
## Building without Superbuild
127+
128+
By default, MAVSDK uses a "superbuild" that automatically downloads and builds all required dependencies. If you prefer to provide dependencies yourself (e.g., from system packages or custom builds), you can disable this with `SUPERBUILD=OFF`.
129+
130+
A script is provided that demonstrates how to build all dependencies and MAVSDK:
131+
132+
```bash
133+
./tools/build-with-system-deps.sh
134+
```
135+
136+
This script:
137+
1. Clones and builds the required dependencies (MAVLink, libevents, PicoSHA2, libmav) into a local `deps/` directory
138+
2. Installs them to `deps-install/`
139+
3. Builds MAVSDK with `SUPERBUILD=OFF` using these dependencies
140+
141+
Prerequisites (install before running the script):
142+
```bash
143+
sudo apt install build-essential cmake git python3 python3-pip \
144+
liblzma-dev libtinyxml2-dev libjsoncpp-dev \
145+
libcurl4-openssl-dev libssl-dev
146+
```
147+
148+
## Troubleshooting
149+
150+
### Git Submodules Out of Date
151+
152+
If you encounter build issues, try updating the submodules:
153+
```bash
154+
git submodule update --recursive
155+
```
156+
157+
### Undefined References
158+
159+
If you get undefined reference errors after installation, update the linker cache:
160+
```bash
161+
sudo ldconfig
162+
```
163+
164+
And try a clean build by wiping the build directory:
165+
```bash
166+
rm -r build
167+
```

docs/en/cpp/guide/build_macos.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Building MAVSDK on macOS
2+
3+
This guide explains how to build MAVSDK from source on macOS systems.
4+
5+
## Requirements
6+
7+
The build requirements are:
8+
- XCode Command Line Tools
9+
- CMake
10+
- Git
11+
12+
### Install Build Tools
13+
14+
First install XCode Command line tools:
15+
```bash
16+
xcode-select --install
17+
```
18+
19+
Then install [Homebrew](https://brew.sh/) and use it to install CMake:
20+
```bash
21+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
22+
brew install cmake
23+
```
24+
25+
## Getting the Source
26+
27+
Download the source using git:
28+
```bash
29+
git clone https://github.com/mavlink/MAVSDK.git
30+
cd MAVSDK
31+
git submodule update --init --recursive
32+
```
33+
34+
## Building the MAVSDK library on macOS
35+
36+
### Debug Build
37+
38+
For development, use the debug build:
39+
```bash
40+
cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild -S.
41+
cmake --build build -j8
42+
```
43+
44+
### Release Build
45+
46+
For production use, build with optimizations enabled:
47+
```bash
48+
cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -S.
49+
cmake --build build -j8
50+
```
51+
52+
## Installation
53+
54+
### System-wide Installation
55+
56+
To install system-wide in `/usr/local`:
57+
```bash
58+
sudo cmake --build build --target install
59+
```
60+
61+
### Local Installation
62+
63+
To install to a local folder, e.g. `install`:
64+
```bash
65+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -Bbuild -S.
66+
cmake --build build --target install
67+
```
68+
69+
## Build for iOS {#build_cpp_iOS}
70+
71+
To build for real iOS devices on macOS:
72+
73+
```bash
74+
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.
75+
cmake --build build/ios
76+
```
77+
78+
Build for the iOS simulator on macOS:
79+
80+
```bash
81+
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.
82+
```
83+
84+
## Build Options
85+
86+
During the configure step you can set various flags using `-DFLAG=Value`:
87+
88+
- `CMAKE_BUILD_TYPE`: Choose between `Debug` and `Release` build
89+
- `CMAKE_INSTALL_PREFIX`: Specify directory to install library artifacts
90+
- `BUILD_SHARED_LIBS`: Set to `ON` for dynamic libraries (.dylib), `OFF` for static libraries (.a)
91+
- `SUPERBUILD`: Set to `OFF` to use system dependencies instead of third party dependencies
92+
- `CMAKE_PREFIX_PATH`: Set path where dependencies can be found if `SUPERBUILD` is `OFF`
93+
- `BUILD_MAVSDK_SERVER`: Set to `ON` to build mavsdk_server
94+
- `BUILD_WITHOUT_CURL`: Set to `ON` to build without CURL support
95+
- `ASAN`: Set to `ON` to enable address sanitizer
96+
- `UBSAN`: Set to `ON` to enable undefined behavior sanitizer
97+
- `LSAN`: Set to `ON` to enable leak sanitizer
98+
- `WERROR`: Set to `ON` to treat warnings as errors
99+
100+
## Troubleshooting
101+
102+
### Git Submodules Out of Date
103+
104+
If you encounter build issues, try updating the submodules:
105+
```bash
106+
git submodule update --recursive
107+
```

0 commit comments

Comments
 (0)