MAVLink Packaging

This page is intended for MAVLink developers only. If you just want to use the common message set, head to Downloading / Installing MAVLink, if you want to generate your own messages / your own dialect, head to generator.

Message Definitions

All mavlink messages are generated off of the definitions under the message_definitions of the mavlink git repository root directory.

Pymavlink is used to generate the C source code from the message definitions. This is the portion of the cmake file that automates this build process. CMake is used here to manage file dependencies and automate package generation as shown later.

# mavlink generation
macro(generateMavlink version definitions)
    foreach(definition ${definitions})
        set(targetName ${definition}-v${version})
        set(definitionAbsPath ${CMAKE_SOURCE_DIR}/message_definitions/v${version}/${definition})
        message(STATUS "processing: ${definitionAbsPath}")
            OUTPUT ${targetName}-stamp
            COMMAND ${PYTHON_EXECUTABLE} ${mavgen} --lang=C --wire-protocol=${version}
                --output=include/v${version} ${definitionAbsPath}
            COMMAND touch ${targetName}-stamp
            DEPENDS ${definitionAbsPath} ${mavgen}
        add_custom_target(${targetName} ALL DEPENDS ${targetName}-stamp)
# build
set(mavgen ${CMAKE_CURRENT_SOURCE_DIR}/pymavlink/generator/


  1. Download cmake version 2.8 or later:
  2. Download and setup git on windows: (Great Sparkfun tutorial on this.)
  3. Using Tortoise git, clone MAVLink.
  4. git clone git:// -b pymavlink_merge 
  5. Use cmake gui, click configure, then click build.
  6. Now navigate to the cmake build directory and type cpack. A nullsoft installer will be produced.


sudo apt-get install cmake
mkdir -P ~/home/Projects && cd ~/home/Projects
git clone git:// -b pymavlink_merge
cd mavlink
mkdir -P build
cd build && cmake ..
cd ~/src/Projects/mavlink
mkdir -P build
cd build && cmake ..

Create a linux installer

If you are running Mac/ or a non-debian linux distribution this will create a self-extracting tarball package. If you are running debian/ubunut it will create a debian installer that you can use to install mavlink on your system.

cd ~/src/Projects/mavlink/build-mingw && cpack

Cross-compiling on Linux for Windows

Install mingw cross env

This will take around 10 hours to complete so do it overnight. You can type make library for a specific library but this ends up being more work.

sudo apt-get install mercurial
mkdir -P ~/home/Projects && cd ~/home/Projects
hg clone
cd mingw-cross-env && make install

Run ranlib over all libs

Some libraries may fail to link correctly. To prevent this rerun ranlib over all the static libraries.

for file in $(find ./usr/i686-pc-mingw32/lib -regex ".+\.a")
    echo fixing $file
   ./user/bin/i686-pc-ming32-ranlib $file

Setup path for cmake-mingw

In the file ~/.profile you should create an alias for cmake-mingw

alias cmake-mingw=cmake -DCMAKE_TOOLCHAIN_FILE=~/home/Projects/mingw-cross-env/usr/i686-pc-mingw32/share/cmake/mingw-cross-env-conf.cmake

Download and compile the code

mkdir -P ~/home/Projects && cd ~/home/Projects
git clone git:// -b pymavlink_merge
cd mavlink
mkdir -P build-mingw
cd build-mingw && cmake-mingw ..

Create a windows installer

This step will create a nullsoft installer that you can use to install mavlink on your system.

cd ~/src/Projects/mavlink/build-mingw && cpack
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported