Building ROS 2 on macOS¶
Table of Contents
We support macOS 10.14 (Mojave).
However, some older versions like 10.13.x are known to work as well.
You need the following things installed to build ROS 2:
If you don’t already have it installed, install Xcode and the Command Line Tools:
xcode-select --install sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
brew (needed to install more stuff; you probably already have this):
Follow installation instructions at http://brew.sh/
Optional: Check that
brewis happy with your system configuration by running:
Fix any problems that it identifies.
brewto install more stuff:
brew install cmake cppcheck eigen pcre poco python3 tinyxml wget # install dependencies for Fast-RTPS if you are using it brew install asio tinyxml2 brew install opencv # install console_bridge for rosbag2 brew install console_bridge # install OpenSSL for DDS-Security brew install openssl # if you are using ZSH, then replace '.bashrc' with '.zshrc' echo "export OPENSSL_ROOT_DIR=$(brew --prefix openssl)" >> ~/.bashrc # install dependencies for rcl_logging_log4cxx brew install log4cxx # install CUnit for Cyclone DDS brew install cunit
Install rviz dependencies
# install dependencies for Rviz brew install qt freetype assimp # Add the Qt directory to the PATH and CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/usr/local/opt/qt export PATH=$PATH:/usr/local/opt/qt/bin
Install rqt dependencies
brew install graphviz pyqt5 sip
Fix some path names when looking for sip stuff during install (see ROS 1 wiki):
ln -s /usr/local/share/sip/Qt5 /usr/local/share/sip/PyQt5
python3 -m pip(just
pipmay install Python3 or Python2) to install more stuff:
python3 -m pip install -U argcomplete catkin_pkg colcon-common-extensions coverage cryptography empy flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes ifcfg lark-parser lxml mock mypy netifaces nose pep8 pydocstyle pydot pygraphviz pyparsing pytest-mock rosdep setuptools vcstool
Please ensure that the
$PATHenvironment variable contains the install location of the binaries (default:
Optional: if you want to build the ROS 1<->2 bridge, then you must also install ROS 1:
Start with the normal install instructions: http://wiki.ros.org/kinetic/Installation/OSX/Homebrew/Source
When you get to the step where you call
rosinstall_generatorto get the source code, here’s an alternate invocation that brings in just the minimum required to produce a useful bridge:
rosinstall_generator catkin common_msgs roscpp rosmsg --rosdistro kinetic --deps --wet-only --tar > kinetic-ros2-bridge-deps.rosinstall wstool init -j8 src kinetic-ros2-bridge-deps.rosinstall
Otherwise, just follow the normal instructions, then source the resulting
install_isolated/setup.bashbefore proceeding here to build ROS 2.
macOS/OS X versions >=10.11 have System Integrity Protection enabled by default.
So that SIP doesn’t prevent processes from inheriting dynamic linker environment variables, such as
DYLD_LIBRARY_PATH, you’ll need to disable it following these instructions.
Create a workspace and clone all repos:
mkdir -p ~/ros2_eloquent/src cd ~/ros2_eloquent wget https://raw.githubusercontent.com/ros2/ros2/eloquent/ros2.repos vcs import src < ros2.repos
If you would like to use another DDS or RTPS vendor besides the default, eProsima’s Fast RTPS, you can find instructions here.
Note: if you are trying to build the ROS 1 <-> ROS 2 bridge, follow instead these modified instructions.
colcon tool to build everything (more on using
colcon in this tutorial):
cd ~/ros2_eloquent/ colcon build --symlink-install
Source the ROS 2 setup file:
This will automatically set up the environment for any DDS vendors that support was built for.
In one terminal, set up the ROS 2 environment as described above and then run a C++
ros2 run demo_nodes_cpp talker
In another terminal source the setup file and then run a Python
ros2 run demo_nodes_py listener
You should see the
talker saying that it’s
Publishing messages and the
I heard those messages.
This verifies both the C++ and Python APIs are working properly.
See the tutorials and demos for other things to try.
See Maintaining a source checkout of ROS 2 to periodically refresh your source installation.
If you installed your workspace with colcon as instructed above, “uninstalling” could be just a matter of opening a new terminal and not sourcing the workspace’s
setupfile. This way, your environment will behave as though there is no Eloquent install on your system.
If you’re also trying to free up space, you can delete the entire workspace directory with:
rm -rf ~/ros2_eloquent