You are here

Compiling MRPT

 

This page describes how to build MRPT from sources. If you want instead to install the binaries and getting quickly into developing your MRPT-based applications, go to the download page and grab the binaries for your system. Please, report errors or doubts on MRPT compilation to the mrpt-users forum.

 

 


1. Prerequisites


 

See this table for a summary of what external libraries MRPT needs and what are they used for, so you can decide which ones are really needed for your application.
 


1.1. On Windows


 

1.1.1 CMake (Mandatory)

To install the CMake build system, follow the instructions at http://www.cmake.org/cmake/resources/software.html
 

Update: I now publish 32bit and 64bit precompiled versions of wxWidgets for Visual Studio 2010 in this page.

In addition to the following notes, read the project's wiki: http://wiki.wxwidgets.org/MSVC Get the source package for the wxWidgets library (named "wxALL" or "wxMSW"), preferably the 2.9.X version currently version 2.8.11) must be downloaded from here and decompressed in a directory where CMake can find it (e.g. C:\wxWidgets).

NOTE: For wxWidgets versions before 2.9 you'll have to manually modify the flag to compile the OpenGL support of wxWidgets. This is achieved by setting wxUSE_GLCANVAS to 1 (the default is 0). This is the part of the file wxwidgets\include\wx\msw\setup.h that has to be modified:

// Setting wxUSE_GLCANVAS to 1 enables OpenGL support. You need to have OpenGL 
// headers and libraries to be able to compile the library with wxUSE_GLCANVAS 
// set to 1. Note that for some compilers (notably Microsoft Visual C++) you 
// will need to manually add opengl32.lib and glu32.lib to the list of 
// libraries linked with your program if you use OpenGL. 
// // Default is 0. 
// // Recommended setting: 1 if you intend to use OpenGL, 0 otherwise 
#define wxUSE_GLCANVAS 1 

 

Build for 64bit:
It took me a while to figure it out, but apparently the easier way to compile wxWidgets for 64bit with Visual Studio is to open the MSVC command-line prompt (from the start menu -> MSVC) and then go to the WXWIDGETS/build/msw directory and run:

nmake -f makefile.vc BUILD=release SHARED=1 RUNTIME_LIBS=dynamic DEBUG_INFO=0 VENDOR=mrpt USE_OPENGL=1 TARGET_CPU=amd64
nmake -f makefile.vc BUILD=debug SHARED=1 RUNTIME_LIBS=dynamic DEBUG_INFO=1 VENDOR=mrpt USE_OPENGL=1 TARGET_CPU=amd64

 

Build for 32bit:
Depending on your version of wxWidgets, open the Visual Studio project (may be called wxwidgets\build\msw\wx_dll.dsw). I recommend to build, with "Build all", only these configurations:

  • DLL Unicode Release (or just "DLL Release" in wxWidgets >=2.9)
  • DLL Unicode Debug (or just "DLL Debug" in wxWidgets >=2.9)

Or use also the command line prompt (from the start menu -> MSVC) and then go to the WXWIDGETS/build/msw directory and run:

nmake -f makefile.vc BUILD=release SHARED=1 RUNTIME_LIBS=dynamic DEBUG_INFO=0 VENDOR=mrpt USE_OPENGL=1
nmake -f makefile.vc BUILD=debug SHARED=1 RUNTIME_LIBS=dynamic DEBUG_INFO=1 VENDOR=mrpt USE_OPENGL=1

 

It is recommended to compile MRPT against OpenCV 2.0.0 (or newer). 

For the latest version check out http://code.opencv.org. Then follow the compiling instructions

Once OpenCV is compiled with CMake, running "Configure" in MRPT's CMake project will automatically detect the OpenCV build directory (where you have generated the projects with CMake) and will use it. If it's not detected, set OpenCV_DIR to the build directory of OpenCV.

 

1.1.4 FFmpeg for Win32 (Optional)

 

The FFmpeg libraries are optional, and they are only needed if you want to use CFFMPEG_InputStream, mainly for supporting IP cameras. Directly download and decompress anywhere in your disk :

Then when running CMake (cmake-gui), enable MRPT_HAS_FFMPEG_WIN32, press "Configure" and then set FFMPEG_WIN32_ROOT_DIR to the directory where FFmpeg binaries have been uncompressed (e.g. "c:\ffmpeg-r16537-gpl-lshared-win32").

The FFmpeg DLLs will be required at runtime by programs compiled with MRPT under Windows, so make sure the directory /bin is in the system PATH.

If you use a modern version of ffmpeg with Visual Studio 2008 (or older) you may find this error at some places:

e:\code\ffmpeg-git-5501afa-win32-dev\include\libavutil\mathematics.h(24) : fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory

... : fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory 

A quick solution is to change those lines to:

#include <mrpt/utils/mrpt_stdint.h>   

or

#include <mrpt/utils/mrpt_inttypes.h>
 

1.1.5 Code Laboratories NUI SDK for Kinect or OpenKinect's freenect (Optional, only if want to use Kinect)

(For MRPT 0.9.3+ or 0.9.4+, respectively)

Please, read this page where all the posibilities are explained.


 

1.1.6 PCL, the Point Cloud Library (Optional)

(Only for MRPT 0.9.5+)

Download, build and install PCL as explained in the official website: http://pointclouds.org/

At present, only a little functionality is provided for interaction of MRPT with PCL (check out the changelogs for details).



1.1.7 Compiler updates

Since MRPT 1.0.0, you'll need Microsoft Visual Studio 2008 Feature Pack to build MRPT with Visual Studio 2008. Otherwise, you'll have errors like:

Fatal error C1083: Cannot open include file: 'unordered_set': No such file or directory

 

 


1.2. On GNU/Linux


 

1.2.1. Dependencies

 

These are the recommended libraries (the development packages!) that should exist in your system (see below for short instructions for Ubuntu/Debian/Fedora). Note that all of them are optional, but most of them are really recommended.

  • OpenCV
  • wxWidgets
  • ffmpeg libraries (libavcodec, libswscale, etc.)
  • Freeglut or glut
  • zlib
  • libjpeg
  • libftdi (optional)
  • libdc1394-22
  • libusb-1.0 (This one is for Kinect support in MRPT 0.9.3+)
  • PCL, the Point Cloud Library (Optional, and only for MRPT 0.9.5+)

1.2.2. About OpenCV

 

It is recommended to compile MRPT against OpenCV 2.0.0 (or newer). For the latest version check out http://code.opencv.org. Then follow the compiling instructions

You can also install the opencv packages for your GNU/Linux distribution (read below for Ubuntu, Debian...)

Under Linux, you'll NOT need to do a "make install" after building OpenCV, since setting the OpenCV_DIR variable in CMake while compiling MRPT is enough.

1.2.3 Ubuntu, Debian

Invoke:

 $ sudo apt-get install build-essential pkg-config cmake \
   libwxgtk2.8-dev libftdi-dev freeglut3-dev \
   zlib1g-dev libusb-1.0-0-dev  \
   libdc1394-22-dev libavformat-dev libswscale-dev \
   lib3ds-dev libjpeg-dev

If you have NOT built OpenCV from sources and want to use opencv 2.1 (or older) from the repositories instead, install:

 $ sudo apt-get install libopencv-dev

For modern versions of Ubuntu (older ones do not provide these packages), also install these libraries so MRPT doesn't use the internal embedded copies of them:

 $ sudo apt-get install libgtest-dev libeigen3-dev

Update Sep/2010: Read this warning for Ubuntu 10.04.


 

1.2.4 Fedora

 

Execute:

 $ su -c 'yum install gcc gcc-c++ make cmake wxGTK-devel opencv-devel freeglut-devel'

 

1.2.5 OpenSUSE

 

For OpenSUSE 10.X, invoke:

 $ sudo zypper install make gcc gcc-c++ cmake cmake-gui pkg-config \
      zlib-devel wxGTK-devel wxGTK-gl libusb-devel freeglut-devel

For OpenSUSE 11.X, invoke:

 $ sudo zypper install make gcc gcc-c++ cmake cmake-gui pkg-config \
      zlib-devel wxGTK-devel wxGTK-gl libusb-devel freeglut-devel 







1.3. On Mac


 

(Building under Mac is not as tested as other platforms, so please let us know on any further instructions. Thanks!)

  1. Install the wxgtk +opengl version of wxWidgets, by executing:
    sudo port install wxgtk +opengl
  2. Generate project with CMake and build as usual. 

 


 


2. CMake build options


 

2.1. Using cmake-gui

 

Open cmake-gui (Available for Windows/Linux) and set the "source dir" to the root directory of the MRPT source package you have downloaded. Set the "binary directory" to a new, empty directory where to generate the project files. Press "configure", check for errors, tune the options as required (read below for a description of some options) and finally click "Generate".

 

2.2. Using cmake from the console

This choice is available for Windows/Linux/MacOS. Go to a new, empty directory where to generate the project/Makefiles files and run:

$ cmake /home/.../MRPT

Replace "/home/.../MRPT" with your actual path to the MRPT source package you have just downloaded. This will use all the default options. To tune them, invoke (available for Linux/MacOS):

$ ccmake .
(Click the image to see it at full size)

 

2.3. Interesting build options

For all platforms/compilers:

  • BUILD_APPLICATIONS : By default ON, if unchecked the applications won't be built. Useful if you only want to build MRPT libraries. Notice that you can also always use the MRPT_BUILD_DIR/libs/MRPT_ALL_LIB.* solution (or Makefile) to achieve the same.
  • BUILD_ARIA : Whether to build or not the embedded ARIA library for interfacing Activemedia Robots. Default is ON. Disable it to save build time if you don't plan to use those robots.
  • BUILD_xSENS : Whether to use the CMT library for interfacing xSens inertial sensors. Default is ON.
  • BUILD_EXAMPLES : Whether you want to compile all the examples in the "/samples" directory. Default is OFF.
  • BUILD_KINECT : By default ON. Uncheck if you don't have the required dependencies (read above for your OS).
  • BUILD_SHARED_LIBS : Build static libraries if set to OFF, or dynamic libraries (.so/.dll) otherwise. Default is ON, and it's strongly recommended to always use shared libs unless you have special need for static ones.
  • EIGEN_USE_EMBEDDED_VERSION : By default ON, instructs MRPT to use the Eigen headers in MRPT/otherlibs/eigen3/. Uncheck if you have Eigen installed in the system and it's visible through pkg-config. It's recommended to uncheck this option if you have eigen3 installed in your system (today, eigen3 it's not yet in any distro repository, that's why it's ON by default).
  • MRPT_ALWAYS_CHECKS_DEBUG : If set to ON, additional security checks will be performed at run-time in many classes. Default is OFF.
  • MRPT_ALWAYS_CHECKS_DEBUG_MATRICES : If set to ON, additional security checks will be performed at run-time in several Matrix operations. Default is ON.
  • MRPT_BACKCOMPATIB_08X: Enable backward compatibility #define's and typedef's so code compiling with MRPT 0.8.X can continue working without problems. Enabled by default. If you start a new project, it may be a good idea to disable it so your new code only uses the more modern MRPT names.
  • MRPT_ENABLE_EMBEDDED_ENABLED_PROFILER : If enabled, all code blocks within macros "MRPT_BEGIN/MRPT_END" will be profiled and the statistics dumped to the console at the end of execution of any program. Default is OFF.
  • MRPT_HAS_ASIAN_FONTS : Enables Asian fonts in mrpt::utils::CCanvas (see this page), but increases library size by 1.5Mb. Default is ON.
  • MRPT_HAS_SVS : To enable integration of the Videre SVS libraries to interface their stereo cameras. You'll need the vendor libraries installed in the system before to enable this option. After setting this option to "ON", the new configuration fields "SVS_ROOT_DIR" will appear and will be tried to be set pointing to the directory where the library is (As of Aug/2010, this option only works in GNU/Linux).
  • MRPT_OCCUPANCY_GRID_CELLSIZE : Can be either 8 or 16 (bits). The size of each cell in the class mrpt::slam::COccupancyGridMap2D. Default is 8 bits. More on this here.
  • PCL_DIR : If you have the Point Cloud Library installed in your system, set this variable to the path to your PCLConfig.cmake file to enable its integration from MRPT.
  • USER_EXTRA_CPP_FLAGS : You can add here whatever additional flags to be passed to the compiler.

 

For Windows only:

  • MRPT_HAS_FFMPEG_WIN32 : Enable this and (after running "Configure") then set FFMPEG_WIN32_ROOT_DIR to the directory where FFmpeg binaries have been uncompressed (e.g. "c:\ffmpeg-r16537-gpl-lshared-win32").
  • MRPT_HAS_BUMBLEBEE : To enable integration of the Bumblebee stereo camera SDK. You'll need the vendor provided "Triclops" and "Digiclops" libraries. After setting this option to "ON", the new configuration fields "BUMBLEBEE_DIGICLOPS_ROOT_DIR" and "BUMBLEBEE_TRICLOPS_ROOT_DIR" will appear where the correct corresponding paths must be entered.

 

For GNU GCC compiler only:

  • MRPT_ENABLE_LIBSTD_PARALLEL_MODE : Enables the GNU libstdc++ parallel mode (See http://gcc.gnu.org/onlinedocs/libstdc++/manual/parallel_mode.html). Default is OFF.
  • MRPT_ENABLE_PROFILING : Enables generation of information required for profiling. Default is OFF.
  • MRPT_OPTIMIZE_NATIVE : Enables optimization for the current architecture (-mtune=native). Default is OFF for old GCC versions, ON for 4.2+. If you have an old version of GCC (<4.2), this option cannot be set since it's not recognized by the compiler. Instead, set USER_EXTRA_CPP_FLAGS to the optimization flags for your platform, for example: -march=pentium4.


 


3. Generate Makefiles/IDE Projects


Just select your preferred Makefile/IDE system with CMake. Supported targets are 32/64 bit Visual Studio projects, Unix Makefiles, Codeblocks projects with MinGW, MinGW Makefiles, etc... For the Eclipse IDE, there exist several ways of integration with CMake.

For Netbeans: 

  • First, make sure to have installed the C/C++ plugin!
  • Menu File -> New Project...: C/C++ -> C/C++ Project with Existing Sources. 
  • Click next and select the MRPT root dir which contains the CMakeList.txt file.
  • In "Select Configuration Mode", choose Automatic and "cmake" should appear as autodetected.


 


4. Compile


Just build as usual: from Visual Studio click on "Build all" for the targets you want to build (Debug or Release), for Unix Makefiles invoke:

$ make -j2

After building everything, it's a good idea to run the tests by building the "test" target under Visual Studio or by "make test" in Unix/MacOS.

 


5. Special instructions for MinGW


  • Install MinGW: Recommended: http://tdm-gcc.tdragon.net/
  • Before compiling MRPT with MinGW, it's strongly recommended to compile wxWidgets and OpenCV with MinGW:
  • Build wxWidgets. Open a command prompt and go to the directory build/msw. Then execute the following commands to rebuild the Release and Debug configurations (as shared libs), so CMake can correctly detect wxWidgets:
    mingw32-make -f makefile.gcc SHARED=1 USE_OPENGL=1 BUILD=release DEBUG_INFO=0 VENDOR=mrpt 
    mingw32-make -f makefile.gcc SHARED=1 USE_OPENGL=1 BUILD=debug DEBUG_INFO=1 VENDOR=mrpt
    
    As usual with make, add a -j4 if you have a DualCore, etc... to compile faster in parallel. For building wxWidgets with MinGW for 64bit you'll need to add TARGET_CPU=amd64 to the parameters above. Otherwise, even with MinGW64 you'll obtain 32bit builds.
  • Build OpenCV. Use its CMake build system, select the MinGW compiler and follow the generic OpenCV compilation instructions.
  • Open cmake-gui and select the source directory and an empty target (binary) directory.
  • Press configure and in the compilers dialog pick MinGW Makefiles. If you obtain an error like:
    CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  
    CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
    
    it means MinGW is not correctly installed in the system. Review the installation process described above.
  • If everything goes fine, you'll see the new CMake variables remarked in red. Go through the normal configuration process for MRPT, and when you are satisfied, press Generate.
  • Open a console and in the newly created binary directory, invoke:
    mingw32-make
    
    either by writing the full path (e.g. c:\MinGW\bin\mingw32-make) or by adding the "bin" directory of your MinGW installation to the system PATH. This should start the normal build process.