Setting up the Build Environment (Linux/Ubuntu)¶

This article shows how to setup your build environment on Linux/Ubuntu machines.

Setup on Ubuntu¶

Get git¶

Git is a free and open source distributed version control system that is used to manage ArduPilot codebase. Git is available on all major OS platforms, and a variety of tools exist to make it easier to get started.

Git command line¶

Ubuntu¶

Linux/Ubuntu users can install with apt :

  • sudo apt-get update

  • sudo apt-get install git

  • sudo apt-get install gitk git-gui

Clone ArduPilot repository¶

"Cloning" is git's term for making a local copy of a remote repository (i.e. one held on the GitHub servers).

Developers should clone the main ArduPilot repository (if they simply want to download and compile the latest code) or their own fork (if they want to make changes to the source code and potentially submit changes back).

Instructions for commonly used tools are below but whichever tool is used, the URL for the source repo will be required. This can be found on the right side of the screen on each Github repository home page but in general the URL is:

  • https://github.com/ArduPilot/ardupilot.git for the main ardupilot repo

  • https://github.com/your-github-account/ardupilot for your fork of the ardupilot repo

../_images/APM-Git-Github-Clone.jpg

Cloning with the command line¶

  • open a terminal and navigate to the directory where you would like the clone to be stored

  • clone your fork:

                                        git                  clone                  https                  :                  //                  github                  .                  com                  /                  your                  -                  github                  -                  userid                  /                  ardupilot                  cd                  ardupilot                  git                  submodule                  update                  --                  init                  --                  recursive                

Note

in case some firewalls do not allow ssh access which can cause the above submodule updates to fail, in this instance you can tell git to unilaterally use https through the following command:

                                git                config                --                global                url                .                "https://"              

to use https protocols instead of the default git:// prefix.

Install some required packages¶

If you are on a debian based system (such as Ubuntu or Mint), we provide a script that will do it for you. From ardupilot directory :

                                Tools                /                environment_install                /                install                -                prereqs                -                ubuntu                .                sh                -                y              

Reload the path (log-out and log-in to make permanent):

Now you should be able to build with waf as described in BUILD.md.

Note

At this point you have already installed the MAVProxy Ground Control Station (MAVProxy GCS) and are also ready to do Software In the Loop (SITL) simulations of the vehicle code. See SITL Simulator (Software in the Loop) and Setting up SITL on Linux. You are ready to not only build the code, but run your build in the ArduPilot SITL simulator.

Cleaning¶

If there have been updates to some git submodules you may need to do a full clean build. To do that use:

that will remove the build artifacts so you can do a build from scratch


ccache for faster builds¶

Installing ccache will speed up your builds a lot. Once you install it (for example with "sudo apt-get install ccache") you should link the compiler into /usr/lib/ccache like this:

                            cd              /              usr              /              lib              /              ccache              sudo              ln              -              s              /              usr              /              bin              /              ccache              arm              -              none              -              eabi              -              g              ++              sudo              ln              -              s              /              usr              /              bin              /              ccache              arm              -              none              -              eabi              -              gcc            

Then add /usr/lib/ccache to the front of your $PATH


Additional Steps for macOS mojave¶

Due to some changes binutils installed via brew have stopped working for macOS mojave leading to crashing builds. So if installed, remove via following command:

Also you will need to install the c++ include headers to /usr/include to do that. Run the following in commandline and follow the installation routine:

                            open              /              Library              /              Developer              /              CommandLineTools              /              Packages              /              macOS_SDK_headers_for_macOS_10              .14              .              pkg            

Setup using Docker¶

Clone ArduPilot repository¶

"Cloning" is git's term for making a local copy of a remote repository (i.e. one held on the GitHub servers).

Developers should clone the main ArduPilot repository (if they simply want to download and compile the latest code) or their own fork (if they want to make changes to the source code and potentially submit changes back).

Instructions for commonly used tools are below but whichever tool is used, the URL for the source repo will be required. This can be found on the right side of the screen on each Github repository home page but in general the URL is:

  • https://github.com/ArduPilot/ardupilot.git for the main ardupilot repo

  • https://github.com/your-github-account/ardupilot for your fork of the ardupilot repo

../_images/APM-Git-Github-Clone.jpg

Cloning with the command line¶

  • open a terminal and navigate to the directory where you would like the clone to be stored

  • clone your fork:

                                        git                  clone                  https                  :                  //                  github                  .                  com                  /                  your                  -                  github                  -                  userid                  /                  ardupilot                  cd                  ardupilot                  git                  submodule                  update                  --                  init                  --                  recursive                

How to Build the Docker Image¶

Build the docker image and tag it with the name ardupilot:

                                docker                build                .                -                t                ardupilot              

Run ArduPilot Container¶

The following command runs the docker container, linking your current directory with the ardupilot source, and launches an interactive shell inside the container. From here you can build ardupilot:

                docker run --rm -it -v `pwd`:/ardupilot ardupilot:latest bash