top of page

Building MAVSDK on Windows

Building MAVSDK on Windows can feel like navigating uncharted territory for developers. While Linux development remains the preferred path for most drone applications, there are compelling reasons to pursue native Windows development, particularly when dealing with network address translation challenges in WSL2 or when you need reliable UDP port communication with autopilots. Windows is the most widely used operating system for desktops and laptops, and that means some organizations will just require a project to be on it.


That’s why Ascend Engineering’s Andrew Brahim and PX4 veteran Julian Oes worked together to make it easier than ever to start building MAVSDK on Windows.

This guide will walk you through building MAVSDK on Windows 11, from dependency installation to running your first MAVLink forwarding application. We'll tackle the common pitfalls and provide a reliable workflow that gets you from zero to a working development environment.

Feel free to follow along with the video or the written tutorial below!


The Stack


MAVSDK

MAVSDK (MAVLink Software Development Kit) provides a modern C++ interface for developing drone applications. It handles the complexity of MAVLink protocol communication, offering clean APIs for telemetry, actions, missions, and real-time drone control.


Visual Studio 2022 Community

Visual Studio serves as our development environment and provides the MSVC compiler toolchain that MAVSDK requires. The Community Edition is free and includes everything needed for C++ development.


CMake

CMake acts as the build system generator, creating Visual Studio project files and managing MAVSDK's complex dependency chain. It's essential for configuring and building the libraries correctly.


Windows 11

We're targeting Windows 11 Home Edition, though the process works equally well on Windows 11 Pro. Windows 10 compatibility hasn't been tested but it should work with the same steps.


Why Native Windows Development?

Before diving into the build process, it's worth understanding why native Windows development matters. WSL2 environments implement network address translation (NAT) that can break UDP communication with autopilots. When your autopilot expects commands on a specific port, WSL2's NAT layer dynamically remaps outbound ports, causing communication failures.


Docker Dev containers are another alternative, but can be difficult to set up and manage, and also abstract a lot of the networking via hidden layers and NATs that make mapping ports between a Windows host and Linux container a feat in itself.


Native Windows applications avoid this network abstraction entirely. Your UDP packets arrive exactly where you send them, ensuring reliable bidirectional communication with flight controllers, ground stations, and Windows-based simulation environments - crucial for drone application development, SITL/HITL testing, and real-time drone operations.


Dependencies and Installation


Visual Studio 2022 Community Edition

Download and install Visual Studio 2022 Community Edition from Microsoft's website. During installation, ensure you select the "Desktop development with C++" workload. This workload includes the Visual C++ build tools, compiler, and linker that MAVSDK requires.


Without this workload, your build attempts will fail with compiler-related errors, so double-check this selection during installation.


CMake

Download the CMake MSI installer rather than the zip archive. The MSI automatically configures system paths and makes CMake available from the command line. This simplifies the build process and avoids path-related issues later.


Git

Ensure Git is installed and accessible from your command line. You'll need it to clone the MAVSDK repository and manage submodules.


Strawberry Perl (Optional)

Strawberry Perl is only required if you're building OpenSSL for secure communications or the MAVSDK server component. Since we're building without these components to minimize build time, Perl isn't necessary for this tutorial. However, if your future applications require HTTPS or you plan to use Python MAVSDK bindings, you'll need to install it.


Building MAVSDK


First, we suggest bookmarking the official documentation. If there are any changes to the workflow, you will find them there, but as of today, this tutorial is up to date with the latest procedure.


Setting Up Your Workspace

Create a clean workspace directory without spaces or special characters in the path. Something like C:\\dev\\workspace works well. Navigate to this directory and clone the MAVSDK repository:

git clone <https://github.com/mavlink/MAVSDK.git>
cd MAVSDK
git submodule update --init --recursive

The submodule update downloads additional libraries and dependencies that MAVSDK requires. This process can take several minutes depending on your internet connection.


Configuring the Build


Crack open MS VIsual Studio 2022. Click open a local folder and navigate to our fresh MAVSDK directory from the last step.

And then open the Developer PowerShell in the bottom left corner.

Checkout the stable v3.5.0 release, which includes significant Windows compatibility improvements:

git checkout v3.5.0

Now, configure the build system using CMake. This command contains several important parameters:

cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install -DBUILD_WITHOUT_CURL=ON -DBUILD_MAVSDK_SERVER=OFF -DBUILD_SHARED_LIBS=OFF -DWERROR=ON -BBuild -S.

Let's break down these parameters:

  • GNinja : Tells CMake to generate Ninja build files instead of Visual Studio projects

  • Bbuild: Places all build artifacts in a "build" directory

  • CMAKE_BUILD_TYPE=RelWithDebInfo: Creates optimized binaries with debugging info

  • CMAKE_INSTALL_PREFIX=install: Creates a clean installation in the "install" directory

  • BUILD_WITHOUT_CURL=ON: Excludes OpenSSL to reduce build time

  • BUILD_MAVSDK_SERVER=OFF: Excludes the server component (not needed for C++ development)

  • BUILD_SHARED_LIBS=OFF: Creates static libraries for easier deployment


The static library configuration is particularly important on Windows. It eliminates DLL deployment complexity by embedding all dependencies directly into your executable.


Building and Installing


Once the configuration completes successfully, build and install MAVSDK:

cmake --build build --config RelWithDebInfo --target install

This process can take anywhere from a few minutes to an hour, depending on your hardware. Modern multi-core systems will parallelize compilation, significantly reducing build times.


You'll see various warnings during compilation - these are generally harmless and don't affect functionality. However, any compilation errors would halt the build and require investigation.


If everything is built right, you should see a mavsdk.lib file in the MAVSDK>install>lib relative path.

Also, within the MAVSDK>install>lib>cmake>MAVSDK relative path, you should find the .cmake files.

And finally, check out the build folder via MAVSDK>build>src>mavsdk for an additional mavsdk.lib file.


Building Your First Application


Navigate to the examples directory and then into the mavlink_forwarding subdirectory.

cd .\\examples\\mavlink_forwarding

Then we can onfigure and build your application:

cmake -G"Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="../../install;../../build/third_party/install" -DCMAKE_INSTALL_PREFIX=install -Bbuild -S.

cmake --build build

The CMAKE_PREFIX_PATH tells CMake where to find the MAVSDK installation you built earlier.


Testing Your Installation


Run your compiled application:

./build/RelWithDebInfo/mavlink_forwarding.exe

The application should start without errors and display MAVSDK version information. Even without a connected autopilot, seeing the application start successfully confirms your build environment is working correctly.

NOTE: The error you see here is related to the absence of an autopilot being connected.

For comprehensive testing, connect an actual autopilot or use a MAVLink simulator. The application should successfully receive and forward messages between different UDP ports.


Next Steps

With a working MAVSDK build environment, you're positioned for more complex drone application development. Consider exploring the various MAVSDK examples to understand different aspects of drone programming:

  • Telemetry examples: Monitor drone status and sensor data

  • Action examples: Command drone movements and behaviors

  • Mission examples: Create and execute autonomous flight plans


As your applications grow in complexity, you might need to revisit the build configuration to include additional MAVSDK components. The modular nature allows you to include only the functionality you need while still providing plug-ins to abstract complex off-board drone functionality.


Conclusion


Building MAVSDK on Windows requires patience and attention to detail, but creates a powerful development environment for drone applications. The combination of Visual Studio's debugging capabilities, Windows' reliable networking, and MAVSDK's comprehensive drone communication features provides an excellent foundation for innovation.


Whether you're building research prototypes, commercial applications, or exploring autonomous behaviors, this foundation supports professional-grade drone development. Take this knowledge and start building something amazing - the drone development community benefits from every new application and innovative approach.

 
 
 

Comments


bottom of page