MacOS Setup
Last updated
Last updated
The following instructions set up a PX4 development environment for macOS. This environment can be used to build PX4 for:
Pixhawk and other NuttX-based hardware
:::tip This setup is supported by the PX4 dev team. To build other targets you will need to use a (or an ). :::
@
The "base" macOS setup installs the tools needed for building firmware, and includes the common tools that will be needed for installing/using the simulators.
:::details Apple M1 Macbook users! If you have an Apple M1 Macbook, make sure to run the terminal as x86 by setting up an x86 terminal:
Locate the Terminal application within the Utilities folder (Finder > Go menu > Utilities)
Select Terminal.app and right-click on it, then choose Duplicate.
Rename the duplicated Terminal app, e.g. to x86 Terminal
Now select the renamed x86 Terminal app and right-click and choose *Get Info
Check the box for Open using Rosetta, then close the window
Run the x86 Terminal as usual, which will fully support the current PX4 toolchain :::
First set up the environment
Enable more open files by appending the following line to the ~/.zshenv
file (creating it if necessary):
:::note If you don't do this, the build toolchain may report the error: "LD: too many open files"
:::
Enforce Python 3 by appending the following lines to ~/.zshenv
To setup the environment to be able to build for Pixhawk/NuttX hardware (and install the common tools for using simulators):
Run these commands in your shell to install the common tools:
Install the required Python packages:
Run the following commands in your shell:
To install SITL simulation with Gazebo Classic:
Run the macOS setup script: PX4-Autopilot/Tools/setup/macos.sh
The easiest way to do this is to clone the PX4 source, and then run the script from the directory, as shown:
Install jMAVSim:
:::warning PX4 v1.11 and beyond require at least JDK 15 for jMAVSim simulation.
Once you have finished setting up the command-line toolchain:
:::tip The daily build includes development tools that are hidden in release builds. It may also provide access to new PX4 features that are not yet supported in release builds. :::
Install Homebrew by following these .
To setup the environment for simulation:
:::note September 2021: The commands above are a workaround to this bug: . They can be removed once it is fixed (along with this note). :::
To setup the environment for simulation:
Install a recent version of Java (e.g. Java 15). You can download or use :
For earlier versions, macOS users might see the error Exception in thread "main" java.lang.UnsupportedClassVersionError:
. You can find the fix in the ). :::
Install (if you prefer using an IDE to the command line).
Install the
Continue to the .