Post · 3 min read· pp. 66–69

Source Installation on macOS

This tutorial will work for macOS Sequoia on Apple Silicon (arm64).

Install tools

The use of some additional tools is recommended to help with the source compilation, although other ways of correctly getting and building the sources are also possible.

The easiest way to get the sources of all libraries is to use vcstool.

To compile all the different libraries and gz-sim in the right order colcon is recommended.

Tools and dependencies for Jetty can be installed using the Homebrew package manager. After installing Homebrew, add the osrf/simulation to Homebrew tap to be able to install prebuilt dependencies.

bash
brew tap osrf/simulation
brew trust osrf/simulation
brew update

Install compiler requirements

Building Gazebo Libraries requires the Xcode Command Line Tools for your version of macOS. They can be installed with:

bash
xcode-select --install

Python 3 from Homebrew

Jetty is compatible with Python 3. Install the latest version from Homebrew:

bash
brew install python3

vcstool and colcon from PyPI

bash
python3 -m venv $HOME/vcs_colcon_installation
. $HOME/vcs_colcon_installation/bin/activate
pip3 install vcstool colcon-common-extensions

Getting the sources

The first step is to create a developer workspace in which vcstool and colcon can work:

bash
mkdir -p ~/workspace/src
cd ~/workspace/src

All the sources of gazebo-jetty are declared in a yaml file. Download it to the workspace:

bash
curl -OL https://raw.githubusercontent.com/gazebo-tooling/gazebodistro/master/collection-jetty.yaml

Use vcstool to automatically retrieve all the Gazebo libraries sources from their repositories:

bash
vcs import < collection-jetty.yaml

The src subdirectory should contain all the sources ready to be built.

Install dependencies

Dependency for Ogre:

bash
brew install --cask xquartz

General dependencies:

bash
brew install assimp boost bullet cli11 cmake cppzmq dartsim doxygen eigen fcl ffmpeg flann freeimage freetype gdal gflags google-benchmark ipopt jsoncpp libccd libyaml libwebsockets libzzip libzip nlopt ode open-scene-graph ossp-uuid ogre1.9 ogre2.3-with-freeimage pkg-config protobuf qt@6 qwt rapidjson ruby tbb tinyxml2 urdfdom zeromq

Building the Gazebo Libraries

Once the compiler and all the sources are in place it is time to compile them. Start the procedure by changing into the workspace and listing the packages recognized by colcon:

bash
cd ~/workspace/
colcon graph

colcon graph should list the Gazebo libraries with an interdependency diagram. If that is the case, then you are ready to build the whole set of libraries:

bash
colcon build --merge-install --cmake-args -DCMAKE_MACOSX_RPATH=FALSE -DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib

Note

The -DCMAKE_MACOSX_RPATH=FALSE and -DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib CMake arguments are only needed on Apple Silicon (ARM) Macs and can be omitted on Intel Macs.

To speed up the build process, you could also disable tests by using

bash
colcon build --merge-install --cmake-args -DBUILD_TESTING=OFF -DCMAKE_MACOSX_RPATH=FALSE -DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib

To use debuggers activate debug symbols. Gazebo will run slower, but you’ll be able to use lldb:

bash
colcon build --merge-install --cmake-args -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MACOSX_RPATH=FALSE -DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib

To build a specific package with all its dependent packages:

bash
colcon build --merge-install --packages-up-to PACKAGE_NAME

To build a single package:

bash
colcon build --merge-install --packages-select PACKAGE_NAME

Visit colcon documentation to view more colcon build and test options.

If there are no errors, all the binaries should be ready to use.

Using the workspace

The workspace needs to be sourced every time a new terminal is used.

Run the following command to source the workspace in zsh (the default macOS shell):

zsh
. ~/workspace/install/setup.zsh

Or if you are using bash:

bash
. ~/workspace/install/setup.bash

You should now be able to launch gazebo:

bash
# launch server in one terminal
gz sim -v 4 shapes.sdf -s

# launch gui in a separate terminal
# remember to source the workspace setup script
gz sim -v 4 -g

This is the end of the source install instructions; head back to the Getting started page to start using Gazebo!

Troubleshooting

See Troubleshooting