Skip to content

Building Gazebo from source

Matteo De Carlo edited this page Oct 21, 2021 · 23 revisions

Gazebo is the backbone of Revolve kit. The current version of Gazebo that we support is Gazebo 10. Here we explain the build instructions for Ubuntu and Mac OS X.

Common

  1. Install the dependencies. See the specifics of your OS below: Ubuntu, Fedora or Mac OS X

  2. Download the project

    git clone https://github.com/ci-group/gazebo.git -b gazebo10-revolve
  3. Install Gazebo on your machine:

    cd gazebo
    mkdir build && cd build
    cmake .. -DENABLE_SSE4=1 \
             -DCMAKE_INSTALL_PREFIX=/usr/local
    make -j4
    make install

    If you don't want to use the debug symbols, run cmake like this:

    cmake .. -DENABLE_SSE4=1 \
             -DCMAKE_BUILD_TYPE=Release \
             -DCMAKE_INSTALL_PREFIX=/usr/local
  4. To test if the simulator is working correctly, follow the OS specific instructions.

[ Ubuntu . Fedora . Mac OS X ]

Build Gazebo on Ubuntu

  1. Make sure you have removed the Ubuntu pre-compiled binaries before installing from source:

    sudo apt-get remove '.*gazebo.*' \
                        '.*sdformat.*' \
                        '.*ignition-math.*' \
                        '.*ignition-msgs.*' \
                        '.*ignition-transport.*'
  2. Install OSRF simulation dependancies:

    sudo apt-get install libignition-cmake-dev \
                         libignition-common-dev \
                         libignition-math4-dev \
                         libignition-msgs-dev \
                         libignition-fuel-tools1-dev \
                         libignition-transport4-dev \
                         libsdformat6-dev \
                         libsimbody-dev
  3. Test if the installation was successful. You can do this in two ways.

  • First, if you run gzserver in verbose mode:

    export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib
    gzserver --verbose

    (Check where the library is installed, either can use lib instead of lib64)

    The result of this command should be:

    Gazebo multi-robot simulator, version 10.1.0
    Copyright (C) 2012-2015 Open Source Robotics Foundation.
    Released under the Apache 2 License.
    http://gazebosim.org
    
    [Msg] Waiting for master.
    [Msg] Connected to gazebo master @ http://127.0.0.1:11345
    [Msg] Publicized address: 192.168.1.72
  • Second, if gzserver works as expected you can run gazebo:

    export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib
    gazebo

    The result of this command should be:


See next: Installation instructions for Revolve


Build Gazebo on Fedora

Dependencies:

sudo dnf install bullet-devel ignition-cmake-devel ignition-transport-devel ignition-msgs-devel ogre-devel boost-devel sdformat-devel qt5-devel protobuf-devel freeimage-devel tbb-devel libtar-devel libcurl-devel tinyxml2-devel qwt-devel
# for recording:
sudo dnf install ffmpeg-devel

Build Gazebo on Archlinux

Dependencies:

sudo pacman -S bullet boost qt5 protobuf freeimage tbb libtar curl tinyxml2 qwt --needed
from aur: ignition-tools ignition-cmake-0 ignition-math-4 ignition-transport-4 ignition-msgs-1 ogre-1.9 sdformat-6 
# for recording:
sudo pacman -S ffmpeg

Build Gazebo on Mac OS X

In a clean Mac OS X installation you can install pre-compiled versions of all dependencies:

  1. If not already available, install Homebrew:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Install XQuartz, which provides X11 support and is required by Gazebo and OGRE.

  3. For 10.8 and earlier, install Xcode command-line tools by downloading them from Apple. For 10.9 and later, the system should prompt you to install them when you install Homebrew in step 1, otherwise install it with:

    xcode-select --install
  4. Install OSRF simulation dependancies:

    brew tap osrf/simulation
    brew install ignition-cmake0 \
                 ignition-common1 \
                 ignition-math4 \
                 ignition-msgs1 \
                 ignition-tools \
                 ignition-transport4 \
                 sdformat6 \
                 qt5 \
                 qwt \
                 tbb@2020 \
                 ogre1.9 \
                 tinyxml2 \
                 bullet \
                 libtar

    For optional dependencies:

    # Model editor's schematic view
    brew install graphviz
    # TODO others?

    You may have problems Qt6 that is currently becoming the new default in brew, in case make sure to remove or unlink the qt6 version and install and link qt5

    brew unlink qt
    brew link qt@5

    This does not seem to solve the problem anymore, the solution is to run cmake with the following Enviroment Variable set:

    Qt5_DIR="$(brew --cellar qt@5)/$(brew list --versions qt@5|tr ' ' '\n'|tail -1)/lib/cmake/Qt5/" \
        cmake .. \
        -DENABLE_SSE4=ON \
        -DCMAKE_BUILD_TYPE=.......(build type here)
    

    If you have some compilation errors with eigen and dartsim, do not worry. Just remove dartsim from your system, we are not using it anyway.

    brew remove dartsim
  5. Link gettext library to /usr/include since some of the dependencies may not link properly:

    brew link --force gettext

    NOTE: If not linked, this type of error occurs during a build-time:

    ld: library not found for -lintl clang: error: linker command failed with exit code 1 (use -v to see invocation)

  6. Download Gazebo

    git clone https://github.com/ci-group/gazebo.git -b gazebo10-revolve
  7. Patch Gazebo If you installed dartsim, the compilation will give some errors in the Eigen library. To fix it you need to apply these two patches:

    curl 'https://bitbucket.org/osrf/gazebo/commits/5ba948b87faf98eb038fc3488e88a07bc4bd9df9/raw' | patch -p1
    curl 'https://bitbucket.org/osrf/gazebo/commits/c7b7f62f76722d57e768b1d2b4c8371841bf856c/raw' | patch -p1
  8. Install Gazebo on your machine:

    cd gazebo
    mkdir build && cd build
    cmake .. -DENABLE_SSE4=1 \
         -DCMAKE_INSTALL_PREFIX=~/installed/gazebo_debug \
         -DQWT_WIN_INCLUDE_DIR=/usr/local/lib/qwt.framework/Headers \
         -DQWT_WIN_LIBRARY_DIR=/usr/local/lib/qwt.framework \
         -DQt5_DIR="$(brew --cellar qt@5)/$(brew list --versions qt@5|tr ' ' '\n'|tail -1)/lib/cmake/Qt5/" \
         -DPKG_CONFIG_PATH=/usr/local/opt/tinyxml2/lib/pkgconfig:/usr/local/opt/ogre1.9/lib/pkgconfig:/usr/local/opt/zmq/lib/pkgconfig:/usr/local/lib/pkgconfig/
    make -j4
    make install

    and check if the right version is installed

    export PATH=~/installed/gazebo_debug/bin:$PATH
    export DYLD_LIBRARY_PATH=~/installed/gazebo_debug/lib/
    
    gazebo --version

    The result of this command should be:

    Gazebo multi-robot simulator, version 10.1.0
    Copyright (C) 2012 Open Source Robotics Foundation.
    Released under the Apache 2 License.
    http://gazebosim.org
  9. Test if the installation was successful. You can do this in two ways.

  • First, if you run gzserver in verbose mode:
    export PATH=~/installed/gazebo_debug/bin:$PATH
    export DYLD_LIBRARY_PATH=~/installed/gazebo_debug/lib/
    
    gzserver --verbose
    The result of this command should be:
    Gazebo multi-robot simulator, version 10.1.0
    Copyright (C) 2012-2015 Open Source Robotics Foundation.
    Released under the Apache 2 License.
    http://gazebosim.org
    
    [Msg] Waiting for master.
    [Msg] Connected to gazebo master @ http://127.0.0.1:11345
    [Msg] Publicized address: 192.168.1.72
  • Second, if gzserver works as expected you can run gazebo:
    export PATH=~/installed/gazebo_debug/bin:$PATH
    export DYLD_LIBRARY_PATH=~/installed/gazebo_debug/lib/
    
    gazebo
    The result of this command should be:

Issues

This is a collection of known issues and solutions

  1. QWT was recently updated and the API changed, causing gazebo not to compile correctly any more. If you have problems compiling gazebo, something related to Plot files QWT functions, applying this patch should fix the issue. https://gist.github.com/portaloffreedom/0540f68adfc82bd3a21f559c4e94f215

See next: Installation instructions for Revolve


_________________
/ Premature      \
| optimization   |
| is the root of |
| all evil.      |
|                |
\ -- D.E. Knuth  /
-----------------
    \   ^__^
     \  (oo)\_______
        (__)\       )\/\
            ||----w |
            ||     ||
Clone this wiki locally