Mac OS X Installation using Homebrew Instructions (10.6 or later)

Note: These instructions are known to have issues. It is recommended to use the electric version of ROS on OS X for now.

SVN Based Install (download-and-compile)

Install Xcode 4

Xcode 4 can be installed from the App Store in Lion, it is a free, but it is a large download. It is required before moving forward.

http://developer.apple.com/technologies/tools/

Install Homebrew

First install Homebrew by running this script in the terminal:

  • /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

(Optional) Change the permissions of your Python, Ruby, and Perl library directories to prevent the need for sudo when running pip. This is recommended by the Homebrew developers, but not strictly necessary.

  • sudo chown -R $USER /Library/Ruby /Library/Perl /Library/Python

Note: If you chose to do the above add this line to your ~/.bashrc file: export ROS_NO_SUDO_PIP=True.

Environment Setup for Homebrew

Add the following lines to your ~/.bashrc file in order to prepare your environment for use each time you open a terminal:

  • export CPLUS_INCLUDE_PATH="/usr/local/include:$CPLUS_INCLUDE_PATH"
    export PYTHONPATH="/usr/local/lib/python2.7/site-packages:/usr/local/lib/python:$PYTHONPATH"

The first line prepends the include directory used by Homebrew so that you can find the headers of Homebrew packages. The second line prepends the default directory for Homebrew-installed Python libraries to the Python path so Python can find them. The third line lets rosdep know that we want to use Homebrew for package resolution.

Execute this line to have these changes take effect:

  • . ~/.bashrc

Install Necessary Dependencies

Install cmake for build systems, wget for fetching files, and libyaml for reading configuration files:

  • brew install wget cmake libyaml --universal

Install pip, which is a package manager for Python, using easy_install:

  • sudo easy_install pip

Install Mercurial, which is a version control system, and PyYaml, which is a python interface to libyaml:

  • sudo pip install mercurial pyyaml

Note: If you opt'ed into the permission changes above in the instructions, you will not need to prepend each of the above easy_install and pip statements with sudo.

rosinstall

The following steps requires two separate installation steps and will compile ROS-related code into two separate places/layers:

  1. Download and install the underlying core ROS libraries and tools into /opt/ros/fuerte.

  2. Download and build some higher-level ROS libraries using rosmake in ~/ros.

The compiled code from (1) is installed into /opt/ros/fuerte. While it is possible to install elsewhere (e.g. /usr), this is not well tested and you will encounter various problems along the way (e.g. having to change rosinstall files, having to manually install system dependencies, etc...). Please see REP 122: Filesystem Hiearchy Layout for more detailed documentation on how the installed files are placed.

The compiled code from (2) is simply built using rosmake, which is familiar to users of previous versions of ROS. The higher-level ROS stacks are download and build in subdirectories inside the ~/ros directory.

First install rosinstall, rospkg and rosdep as described in their instructions:

If you have trouble using rosws/rosinstall, you can manually download the projects by investigating the respective rosinstall file.

Layer 1: Install core libraries

The following instructions will create a system install of the core ROS libraries and tools. The installation is done using standard CMake/make tools, so experts can adjust to their liking.

  • ROS-Full: ROS package, build, communication, tutorials and graphical tools.

    • rosinstall --catkin ~/ros-underlay http://ros.org/rosinstalls/fuerte-ros-full.rosinstall

    ROS-Base: (Bare Bones) ROS package, build, and communication libraries.

    • rosinstall --catkin ~/ros-underlay http://ros.org/rosinstalls/fuerte-ros-base.rosinstall

For people having trouble with rosinstall or catkin on their particular OS: If you have downloaded the source files in a different way, you need to run catkin_init_workspace ~/ros-underlay. This script is part of catkin, which should by now also at least be in your workspace, you can use the script without installing catkin. It should create a suitable global CMakeLists.txt to use in the next step.

If you do not want to use catkin, follow standard cmake procedure for building cmake packages, and install the packages in the dependency order by manually checking the package.xml declarations.

Build and install the underlay into /opt/ros/fuerte:

  • cd ~/ros-underlay
    mkdir build
    cd build

Now, run cmake. The invocation depends on the platform you are on:

  • Debian-based platforms (e.g. Ubuntu, Mint) use:
    cmake .. -DCMAKE_INSTALL_PREFIX=/opt/ros/fuerte
    Other platforms use:
    cmake .. -DCMAKE_INSTALL_PREFIX=/opt/ros/fuerte -DSETUPTOOLS_DEB_LAYOUT=OFF

Finally, build + install the code:

  • make -j8
    sudo make install

Useful TIP: If you encounter problems with the make command due to "Unable to find 'swig.swg'" and "Unable to find 'python.swg'" errors then it probably due to the installation script having placed /swig at the toplevel/root directory.

To get around this problem do the following (and then restart make process as above)

cd /
sudo cp -r /swig /usr/local/share
cd ~/ros-underlay/build

Useful TIP: If you are having trouble with the make install command due to lib64 and lib problems, a work around is

cd /opt/ros/fuerte/
sudo mv lib/* lib64/
sudo rmdir lib
sudo ln -s lib64 lib

This makes the lib and the lib64 directory linked together and the make install command should work now.

Verify the installed environment:

  • . /opt/ros/fuerte/setup.sh
    which roscore

You should see:

  • /opt/ros/fuerte/bin/roscore

You can delete ~/ros-underlay now, if you wish. The ROS core libraries are now installed onto your system.

Layer 2: Higher-level robotics libraries and tools

Now it's time to create the second layer, which contains your main robotics libraries (e.g. navigation) as well as visualization tools like rviz. You will build this layer using rosmake, but it is not installed.

There are many different libraries and tools in ROS. We provided four default configurations to get you started.

NOTE: The rosinstall installation files below assume that you've installed into /opt/ros/fuerte, so you will need to change them manually if you have a different install path.

  • Desktop-Full Install: (Recommended): ROS Full, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception

    • rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=desktop-full&overlay=no"

    Desktop Install: : ROS Full, rviz, and robot-generic libraries

    • rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=desktop&overlay=no"

NOTE: the instructions above download all stacks inside the ~/ros folder. If you prefer a different location, simply change the ~/ros in the commands above.

Please reference REP 113 for description of other available configurations.

Environment Setup

Shell language:   Bash     Zsh    

You'll now need to update your environment. You can do this by typing:

source ~/ros/setup.bash

It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched, which you can do with the command below:

echo "source ~/ros/setup.bash" >> ~/.bashrc
. ~/.bashrc

You'll now need to update your environment. You can do this by typing:

source ~/ros/setup.zsh

It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched, which you can do with the command below:

echo "source ~/ros/setup.zsh" >> ~/.zshrc
. ~/.zshrc

Build Higher-level/tools (Layer 2)

First, initialize your rosdep. ROS Fuerte comes with rosdep 2. If you get a message that your default sources list exists, then don't worry as it means you've done this before.

  • sudo rosdep init
    rosdep update

Now, use rosdep 2 to install system dependencies. Many of the system dependencies will install into /opt/ros/fuerte and will not be usable if you have changed the installation prefix.

  • rosdep install -a

Useful TIP: to get rid of constant prompts of being sure with proceeding, you can use -y switch to tell the package manager to default 'Yes' while installing.

  • rosdep install -ay

Finally, build the ROS stacks using rosmake.

  • rosmake -a

Notes About Installing with Hombrew

There a few things that developers should know about using Homebrew.

Pip is used for Python Packages

Homebrew only provides packages that do not ship with OS X or Python packages that cannot be installed via pip. Therefore in addition to Homebrew installing things to /usr/local/, this ROS setup leverages easy_install and pip from the system Python provided by Apple to install Python package dependencies.

Macports Conflicts with Homebrew

Additionally, Homebrew is known to have conflicts with Macports. If you are using Macports and want to try out the ROS with Homebrew setup, I recommend temporarily moving the Macports folder to prevent conflicting libraries:

  • sudo mv /opt/local /opt/_local

To restore Macports at a later date simply rename the folder back to the original name.

wxPython and wxWidgets are installed from a Binary

Because of difficulties in reproducing a wxPython/wxWidgets build that is cocoa compliant, a development binary installer is used. This installer is downloaded and run automatically for you by rosdep, but you will be prompted for sudo credentials, so if you just rosmake --rosdep-install rviz keep an eye out for rosdep asking for your password.

nVidia CG toolkit is Installed from a Binary

In addition to wxPython, nVidia's CG toolkit is installed from a binary. It will also install automatically and prompt you for sudo credentials.

rosconsole may need an additional patch

In case rosconsole fails to build because of a "g++-4.2 not found" error, use the patch found here: https://code.ros.org/trac/ros/changeset/15411

Cairo may have to be built using clang

In case Homebrew fails to build Cairo, use the following command:

brew install cairo --use-clang

in case OGRE refuses to built

In case OGRE refuses to build with the error "BUILD FAILED: Plugin_CgProgramManager.so not created. Is nvidia-cg-toolkit installed?", this fix is known to work:

( cd visualization_common/ogre ; rm installed_osx ; make )

See this answers.ros.org question for the solution to another OGRE build problem.

Troubleshooting

Unsigned Certificate (or hang at first `rosinstall`)

You might get this error the first time you run rosinstall:

∫ rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=desktop-full&overlay=no"
rosinstall operating on /Users/someuser/ros from specifications in rosinstall files  /Users/someuser/ros/.rosinstall, http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=desktop-full&overlay=no
Installing https://code.ros.org/svn/ros/stacks/ros/tags/ros-1.6.5  to /Users/someuser/ros/ros
Error validating server certificate for 'https://code.ros.org:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: *.ros.org
 - Valid: from Thu, 10 Sep 2009 23:16:35 GMT until Wed, 12 Sep 2012 05:05:53 GMT
 - Issuer: Equifax Secure Certificate Authority, Equifax, US
 - Fingerprint: fb:45:70:74:bf:12:94:01:05:23:8d:ee:b2:04
(R)eject, accept (t)emporarily or accept (p)ermanently?

Visit https://code.ros.org/ in your web browser, pull up the certificate information, and verify the fingerprint in your browser matches the one shown by rosinstall (or svn co). If it does, simply accept it permanently, by pressing 'p' and 'enter', to solve the problem.

This may also manifest as a hang during your first rosinstall invocation:

rosinstall operating on /Users/someuser/ros from specifications in rosinstall files  http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=desktop-full&overlay=no
(Over-)Writing /Users/someuser/ros/.rosinstall
[ros] Installing https://code.ros.org/svn/ros/stacks/ros/tags/ros-1.6.8 (None) to /Users/someuser/ros/ros

Hit ^C to abort the installation, and try running svn co by hand using the URL in the output above:

svn co https://code.ros.org/svn/ros/stacks/ros/tags/ros-1.6.8 ~/ros/ros

You should then get the same certificate error and prompt above, and you can resolve it as discussed there.

Log4cxx Installation Hangs

There have been reports that during the make install step of installing log4cxx the process will hang. You can sometimes tell this has happened when the cpu usage stays low for a long time during the make install step of log4cxx. This might have to do with the automated install of java when building log4cxx on a "clean" OS X install.

To remedy this simply cancel the process with ctrl-c and then rerun the previous command. It should install successfully the second time through. If it is does not ask a question on http://answers.ros.org/questions/.

`rosconsole` Fails with no g++-4.2

If you get this error when building rosconsole:

mkdir -p bin
cd build && cmake -Wdev -DCMAKE_TOOLCHAIN_FILE=`rospack find rosbuild`/rostoolchain.cmake  ..
[rosbuild] Building package rosconsole
[rosbuild] Including /Users/william/ros/ros_comm/clients/roslisp/cmake/roslisp.cmake
[rosbuild] Including /Users/william/ros/ros_comm/clients/rospy/cmake/rospy.cmake
[rosbuild] Including /Users/william/ros/ros_comm/clients/cpp/roscpp/cmake/roscpp.cmake
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_TOOLCHAIN_FILE


-- Build files have been written to: /Users/william/ros/ros_comm/tools/rosconsole/build
cd build && make 
[  0%] Built target rospack_genmsg_libexe
[  0%] Built target rosbuild_precompile
[ 50%] Building CXX object CMakeFiles/rosconsole.dir/src/rosconsole/rosconsole.o
make[3]: /usr/bin/g++-4.2: No such file or directory
make[3]: *** [CMakeFiles/rosconsole.dir/src/rosconsole/rosconsole.o] Error 1
make[2]: *** [CMakeFiles/rosconsole.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

Apply this patch: https://code.ros.org/trac/ros/attachment/ticket/3626/ros_comm-1.6.5-rosconsole_g%2B%2B-4.2.patch

From this ticket: https://code.ros.org/trac/ros/ticket/3626

Mercurial fails with an import error

If you see this error when trying to run hg:

bash-3.2$ hg
Traceback (most recent call last):
 File "/usr/local/bin/hg", line 38, in <module>
   mercurial.dispatch.run()
 File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 27, in run
   sys.exit(dispatch(request(sys.argv[1:])))
 File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 40, in dispatch
   req.ui = uimod.ui()
 File "/Library/Python/2.7/site-packages/mercurial/ui.py", line 43, in __init__
   for f in scmutil.rcpath():
 File "/Library/Python/2.7/site-packages/mercurial/scmutil.py", line 399, in rcpath
   _rcpath = osrcpath()
 File "/Library/Python/2.7/site-packages/mercurial/scmutil.py", line 371, in osrcpath
   path = systemrcpath()
 File "/Library/Python/2.7/site-packages/mercurial/scmutil.py", line 420, in systemrcpath
   path.extend(rcfiles(os.path.join(p, 'etc/mercurial')))
 File "/Library/Python/2.7/site-packages/mercurial/scmutil.py", line 409, in rcfiles
   for f, kind in osutil.listdir(rcdir)
 File "/Library/Python/2.7/site-packages/mercurial/demandimport.py", line 86, in __getattribute__
   self._load()
 File "/Library/Python/2.7/site-packages/mercurial/demandimport.py", line 58, in _load
   mod = _origimport(head, globals, locals)
ImportError: dlopen(/Library/Python/2.7/site-packages/mercurial/osutil.so, 2): no suitable image found.  Did find:
       /Library/Python/2.7/site-packages/mercurial/osutil.so: mach-o, but wrong architecture

Then your Python interpreter is running in 32-bit mode. To put it in 64-bit mode:

defaults write com.apple.versioner.python Prefer-32-Bit -bool no

Tutorials

Now, to test your installation, please proceed to the ROS Tutorials.

Wiki: fuerte/Installation/OSX/Homebrew (last edited 2012-05-21 21:38:28 by WilliamWoodall)