Skip to content

Instantly share code, notes, and snippets.

@pgorczak
Forked from mikepurvis/gist:9837958
Last active June 25, 2016 20:36
Show Gist options
  • Save pgorczak/66f99462bf251afbd2bc to your computer and use it in GitHub Desktop.
Save pgorczak/66f99462bf251afbd2bc to your computer and use it in GitHub Desktop.

Building ROS on OS X

This is a fork of @mikepurvis original ROS indigo installation notes. I tried to find a straightforward way to keep the system Python throughout the build. I ran into some well known issues while building rviz and had to extend the header exclusions for moc a bit more.

Helpful Stuff

catkin build options
  • -p # (parallel jobs)
  • catkin build pkg_name to build a certain package with dependencies
  • --start-with pkg_name skip dependencies up to a certain package
  • the two above combined allow for a quick retry if one package keeps failing

Issues

ecto_pcl

I am currently getting undefined symbol errors when trying to build.

opencv_candidate/ecto_opencv

The clang compiler that comes with OS X doesn't support OpenMP. The package opencv_candidate depends on OpenMP, so it is necessary to replace the compiler. It seems to be possible to build your own clang with OpenMP support (instructions) but I haven't tried that yet.

# NOTE: These instructions do not represent a robust, self-troubleshooting install; they
# are definitely not suitable for dumping to a giant script and running as one. If you
# use them, they should be run one at a time, with an eye out for errors or problems
# along the way.
#
# If you haven't already, install XQuartz using the installer from its own website:
# https://xquartz.macosforge.org
# Homebrew (if you haven't yet got it)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
source .bash_profile
brew doctor
brew update
# pip for system Python
curl -O https://bootstrap.pypa.io/get-pip.py && sudo python get-pip.py
# Homebrew taps for prerequisites
brew tap ros/deps
brew tap osrf/simulation
brew tap homebrew/versions
brew tap homebrew/science
# ROS infrastructure tools
sudo pip install -U setuptools rosdep rosinstall_generator wstool rosinstall catkin_tools catkin_pkg bloom
sudo rosdep init
rosdep update
# ROS Indigo Source Install
mkdir indigo_desktop_ws && cd indigo_desktop_ws
rosinstall_generator desktop --rosdistro indigo --deps --tar --exclude visualization_tutorials > indigo_desktop.rosinstall
wstool init -j8 src indigo_desktop.rosinstall
rosinstall_generator rviz --rosdistro hydro --tar > hydro_rviz.rosinstall # Version of rviz from Hydro
wstool merge -t src hydro_rviz.rosinstall # You might want to do this on every source-update
wstool update -t src
# Package dependencies. Note that you may have an unresolved urdfdom key. This is due to
# using Hydro's rviz. You can ignore it, but if it troubles you, change the build and run
# depend keys in indigo_desktop_ws/src/rviz/package.xml from urdfdom to liburdfdom-headers-dev
# and liburdfdom-dev, respectively.
# In order to keep the system Python throughout the build process, use the shell script attached below.
./pre-rosdep.sh
# I needed to patch a couple of rviz files because my Qt+Ogre+boost didn't seem to like each other.
# The issue has been reported and interestingly enough, there are some new recent comments in the thread.
# https://bugreports.qt.io/browse/QTBUG-22829
git apply --directory src/rviz rviz_moc.patch
# Parallel build
sudo mkdir -p /opt/ros/indigo
sudo chown $USER /opt/ros/indigo
catkin config --install --install-space /opt/ros/indigo
catkin build -DCMAKE_BUILD_TYPE=Release
source /opt/ros/indigo/setup.bash
# Run this from the Catkin workspace root after downloading the ROS sources.
# This script helps with keeping the system Python throughout a ROS distribution
# build. It finds brew dependencies via rosdep and builds them from source if
# they depend on the "brewed" Python. This way the packages are built against
# the system Python instead of installing the "brewed" Python and packages
# pre-built against it[1].
# Shoutout to [2] for telling us how to crawl brew dependencies.
# [1] https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md#why-is-homebrews-python-being-installed-as-a-dependency
# [2] http://zanshin.net/2014/02/03/how-to-list-brew-dependencies/
tmpfile=`mktemp -t rosdep`
echo "Looking for brew dependencies..."
rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r -s | awk '/brew\ install/ {print $3}' | while read cask ; do
printf "Scanning deps of \e[1;34m$cask\e[0m... "
brew deps $cask | if grep -q ^python$ ; then
printf "\e[0;31mdepends on python. \e[0m"
echo "$cask" >> "$tmpfile"
else
printf "no python deps."
fi
printf "\n"
done
if [ -s $tmpfile ] ; then
printf "Packages with python dependencies: \e[0;31m"
cat $tmpfile | xargs printf
printf "\e[0m\n"
printf "Install them with --build-from source? (y/n) "
read install
if [ "$install" = "y" ] ; then
cat $tmpfile | xargs brew install --build-from-source
fi
else
echo "No packages depend on python."
fi
rm $tmpfile
printf "Run a final rosdep install? (y/n) "
read installrosdep
if [ "$installrosdep" = "y" ] ; then
rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r
fi
diff --git a/src/rviz/default_plugin/camera_display.h b/src/rviz/default_plugin/camera_display.h
index 6cf3970..222e341 100644
--- a/src/rviz/default_plugin/camera_display.h
+++ b/src/rviz/default_plugin/camera_display.h
@@ -32,11 +32,11 @@
#include <QObject>
+#ifndef Q_MOC_RUN
#include <OgreMaterial.h>
#include <OgreRenderTargetListener.h>
#include <OgreSharedPtr.h>
-#ifndef Q_MOC_RUN
# include <sensor_msgs/CameraInfo.h>
# include <message_filters/subscriber.h>
diff --git a/src/rviz/default_plugin/effort_display.h b/src/rviz/default_plugin/effort_display.h
index 8b95b93..bc89bd6 100644
--- a/src/rviz/default_plugin/effort_display.h
+++ b/src/rviz/default_plugin/effort_display.h
@@ -1,7 +1,9 @@
#ifndef EFFORT_DISPLAY_H
#define EFFORT_DISPLAY_H
+#ifndef Q_MOC_RUN
#include <boost/circular_buffer.hpp>
+#endif
#include <sensor_msgs/JointState.h>
#include <rviz/message_filter_display.h>
diff --git a/src/rviz/default_plugin/interactive_markers/interactive_marker.h b/src/rviz/default_plugin/interactive_markers/interactive_marker.h
index 332456a..c8a2ac7 100644
--- a/src/rviz/default_plugin/interactive_markers/interactive_marker.h
+++ b/src/rviz/default_plugin/interactive_markers/interactive_marker.h
@@ -35,8 +35,10 @@
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
+#ifndef Q_MOC_RUN
#include <OgreVector3.h>
#include <OgreQuaternion.h>
+#endif
#include <visualization_msgs/InteractiveMarker.h>
#include <visualization_msgs/InteractiveMarkerPose.h>
diff --git a/src/rviz/default_plugin/interactive_markers/interactive_marker_control.h b/src/rviz/default_plugin/interactive_markers/interactive_marker_control.h
index 0806c82..e99a7e7 100644
--- a/src/rviz/default_plugin/interactive_markers/interactive_marker_control.h
+++ b/src/rviz/default_plugin/interactive_markers/interactive_marker_control.h
@@ -36,10 +36,12 @@
#include <QCursor>
+#ifndef Q_MOC_RUN
#include <OgreRay.h>
#include <OgreVector3.h>
#include <OgreQuaternion.h>
#include <OgreSceneManager.h>
+#endif
#include <visualization_msgs/InteractiveMarkerControl.h>
diff --git a/src/rviz/default_plugin/map_display.h b/src/rviz/default_plugin/map_display.h
index f733dfd..7d72a94 100644
--- a/src/rviz/default_plugin/map_display.h
+++ b/src/rviz/default_plugin/map_display.h
@@ -32,10 +32,12 @@
#include <boost/thread/thread.hpp>
+#ifndef Q_MOC_RUN
#include <OgreTexture.h>
#include <OgreMaterial.h>
#include <OgreVector3.h>
#include <OgreSharedPtr.h>
+#endif
#include <nav_msgs/MapMetaData.h>
#include <ros/time.h>
diff --git a/src/rviz/default_plugin/point_cloud_transformer.h b/src/rviz/default_plugin/point_cloud_transformer.h
index f20b90c..f72f570 100644
--- a/src/rviz/default_plugin/point_cloud_transformer.h
+++ b/src/rviz/default_plugin/point_cloud_transformer.h
@@ -34,8 +34,10 @@
#include <ros/message_forward.h>
+#ifndef Q_MOC_RUN
#include <OgreVector3.h>
#include <OgreColourValue.h>
+#endif
#include <rviz/ogre_helpers/point_cloud.h>
diff --git a/src/rviz/default_plugin/point_display.h b/src/rviz/default_plugin/point_display.h
index c7aeccf..2f2597c 100644
--- a/src/rviz/default_plugin/point_display.h
+++ b/src/rviz/default_plugin/point_display.h
@@ -1,7 +1,9 @@
#ifndef POINT_DISPLAY_H
#define POINT_DISPLAY_H
+#ifndef Q_MOC_RUN
#include <boost/circular_buffer.hpp>
+#endif
#include <geometry_msgs/PointStamped.h>
#include <rviz/message_filter_display.h>
diff --git a/src/rviz/default_plugin/wrench_display.h b/src/rviz/default_plugin/wrench_display.h
index 31999e4..38b3500 100644
--- a/src/rviz/default_plugin/wrench_display.h
+++ b/src/rviz/default_plugin/wrench_display.h
@@ -1,7 +1,9 @@
#ifndef WRENCHSTAMPED_DISPLAY_H
#define WRENCHSTAMPED_DISPLAY_H
+#ifndef Q_MOC_RUN
#include <boost/circular_buffer.hpp>
+#endif
#include <geometry_msgs/WrenchStamped.h>
#include <rviz/message_filter_display.h>
diff --git a/src/rviz/message_filter_display.h b/src/rviz/message_filter_display.h
index 2d3eea7..86778d2 100644
--- a/src/rviz/message_filter_display.h
+++ b/src/rviz/message_filter_display.h
@@ -29,10 +29,10 @@
#ifndef MESSAGE_FILTER_DISPLAY_H
#define MESSAGE_FILTER_DISPLAY_H
+#ifndef Q_MOC_RUN
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
-#ifndef Q_MOC_RUN
#include <message_filters/subscriber.h>
#include <tf/message_filter.h>
#endif
diff --git a/src/rviz/ogre_helpers/point_cloud.h b/src/rviz/ogre_helpers/point_cloud.h
index 8812868..f982932 100644
--- a/src/rviz/ogre_helpers/point_cloud.h
+++ b/src/rviz/ogre_helpers/point_cloud.h
@@ -30,6 +30,7 @@
#ifndef OGRE_TOOLS_OGRE_POINT_CLOUD_H
#define OGRE_TOOLS_OGRE_POINT_CLOUD_H
+#ifndef Q_MOC_RUN
#include <OgreSimpleRenderable.h>
#include <OgreMovableObject.h>
#include <OgreString.h>
@@ -40,6 +41,7 @@
#include <OgreRoot.h>
#include <OgreHardwareBufferManager.h>
#include <OgreSharedPtr.h>
+#endif
#include <stdint.h>
diff --git a/src/rviz/pluginlib_factory.h b/src/rviz/pluginlib_factory.h
index 13f10ef..7b24bbc 100644
--- a/src/rviz/pluginlib_factory.h
+++ b/src/rviz/pluginlib_factory.h
@@ -36,7 +36,9 @@
#include <string>
#include <vector>
+#ifndef Q_MOC_RUN
#include <pluginlib/class_loader.h>
+#endif
#include "rviz/class_id_recording_factory.h"
#include "rviz/load_resource.h"
diff --git a/src/rviz/render_panel.h b/src/rviz/render_panel.h
index 1885fa7..c58c58e 100644
--- a/src/rviz/render_panel.h
+++ b/src/rviz/render_panel.h
@@ -32,7 +32,9 @@
#include "ogre_helpers/qt_ogre_render_window.h"
+#ifndef Q_MOC_RUN
#include <OgreSceneManager.h>
+#endif
#include <boost/thread/mutex.hpp>
diff --git a/src/rviz/robot/robot_joint.h b/src/rviz/robot/robot_joint.h
index 4835fe5..ba8a832 100644
--- a/src/rviz/robot/robot_joint.h
+++ b/src/rviz/robot/robot_joint.h
@@ -35,10 +35,12 @@
#include <QObject>
+#ifndef Q_MOC_RUN
#include <OgreVector3.h>
#include <OgreQuaternion.h>
#include <OgreAny.h>
#include <OgreMaterial.h>
+#endif
#include "rviz/ogre_helpers/object.h"
#include "rviz/selection/forwards.h"
diff --git a/src/rviz/robot/robot_link.h b/src/rviz/robot/robot_link.h
index a07a53e..31e8e6f 100644
--- a/src/rviz/robot/robot_link.h
+++ b/src/rviz/robot/robot_link.h
@@ -35,11 +35,13 @@
#include <QObject>
+#ifndef Q_MOC_RUN
#include <OgreVector3.h>
#include <OgreQuaternion.h>
#include <OgreAny.h>
#include <OgreMaterial.h>
#include <OgreSharedPtr.h>
+#endif
#include "rviz/ogre_helpers/object.h"
#include "rviz/selection/forwards.h"
diff --git a/src/rviz/selection/forwards.h b/src/rviz/selection/forwards.h
index b177c8b..101c939 100644
--- a/src/rviz/selection/forwards.h
+++ b/src/rviz/selection/forwards.h
@@ -34,8 +34,11 @@
#include <set>
#include <map>
#include <boost/unordered_map.hpp>
+
+#ifndef Q_MOC_RUN
#include <OgrePixelFormat.h>
#include <OgreColourValue.h>
+#endif
#include <ros/console.h>
diff --git a/src/rviz/selection/selection_handler.h b/src/rviz/selection/selection_handler.h
index fd2f19f..6248a60 100644
--- a/src/rviz/selection/selection_handler.h
+++ b/src/rviz/selection/selection_handler.h
@@ -36,7 +36,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>
+#ifndef Q_MOC_RUN
#include <OgreMovableObject.h>
+#endif
#include "rviz/selection/forwards.h"
#include "rviz/selection/selection_handler.h"
diff --git a/src/rviz/selection/selection_manager.h b/src/rviz/selection/selection_manager.h
index 505278d..b289c64 100644
--- a/src/rviz/selection/selection_manager.h
+++ b/src/rviz/selection/selection_manager.h
@@ -41,12 +41,14 @@
#include <boost/unordered_map.hpp>
#include <boost/thread/recursive_mutex.hpp>
+#ifndef Q_MOC_RUN
#include <OgreTexture.h>
#include <OgreMaterial.h>
#include <OgreMaterialManager.h>
#include <OgreMovableObject.h>
#include <OgreRenderQueueListener.h>
#include <OgreSharedPtr.h>
+#endif
#include <vector>
#include <set>
--
1.9.3 (Apple Git-50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment