Skip to content

Building Mitsuba on CentOS

benjamin-heasly edited this page Mar 28, 2013 · 18 revisions

The RenderToolbox3 team has access to a computing cluster called Rhino, which is based on the [CentOS] (http://en.wikipedia.org/wiki/CentOS) version 5.9 Linux distribution. We were able to build Mitsuba on Rhino, but it took some extra steps because we don't have root privileges on Rhino. Instead of installing and updating Mitsuba's dependencies the normal way, with the yum package manager, we had to build them by hand.

For reference, here are the packages we would have installed or updated if we were building Mitsuba the normal way:

sudo yum install/update mercurial gcc-c++ scons boost-devel qt4-devel OpenEXR-devel xerces-c-devel python-devel glew-devel libpng-devel libjpeg-devel collada-dom-devel eigen3-devel pcre-devel

Most of these packages were present, but most of them were too old for Mitsuba version 0.4.4.

Here are the extra steps we took to build Mitsuba and its dependencies. These are specific to our situation, but we hope they will be helpful if you find yourself in a similar situation.

Our general approach was to install things in the /home2/brainard folder that we have access to. In particular:

  • /home2/brainard/src contains source code that we downloaded
  • /home2/brainard/dependencies contains Mitsuba dependencies that we built
  • /home2/brainard/mitsuba contains Mitsuba that we built
  • /home2/brainard/bin contains links to Mitsuba executables
  • /home2/brainard/test contains output data from testing Mitsuba

SCons

Mitsuba uses the SCons build system, version 2.0 or later. We installed Scons like so:

cd /home2/brainard/src
wget 'http://sourceforge.net/projects/scons/files/scons/2.3.0/scons-2.3.0.tar.gz/download'
tar xzf scons-2.3.0.tar.gz
cd scons-2.3.0
python setup.py build 2>&1 | tee log.build
python setup.py install --home /home2/brainard/dependencies/scons-2.3.0 2>&1 | tee log.install
ln -s /home2/brainard/dependencies/scons-2.3.0 /home2/brainard/dependencies/scons

Commands like 2>&1 | tee log.build cause error messages and output messages to be saved in a log file.

Python

SCons is a Python-based build system. Building Mitsuba with SCons requires an updated Python version, such as Python 2.7.3.

Fortunately, we found Python 2.7.3 in an alternate location on our Rhino system:

/usr/global/python-2.7.3-intel/bin/python

It should also be straightforward to download and install Python with instructions like these from Stack Overflow.

Boost

Mitsuba uses some of the Boost libraries. Many Boost libraries are header-only and therefore easy to incorporate into a project. Mitsuba also uses some Boost libraries that have to be compiled separately and linked. We installed the necessary Boost libraries like so:

cd /home2/brainard/src
wget 'http://sourceforge.net/projects/boost/files/boost/1.53.0/boost_1_53_0.tar.gz/download'
tar xzf boost_1_53_0.tar.gz
cd boost_1_53_0
./bootstrap.sh --prefix=/home2/brainard/dependencies/boost_1_53_0 --with-libraries=thread,python,system,filesystem 2>&1 | tee log.bootstrap
./b2 2>&1 | tee log.b2
./b2 install 2>&1 | tee log.b2
ln -s /home2/brainard/dependencies/boost_1_53_0/ /home2/brainard/dependencies/boost

Xerces

Mitsuba depends on the Xerces XML library. We installed Xerces like so:

cd /home2/brainard/src
wget 'http://mirror.reverse.net/pub/apache//xerces/c/3/sources/xerces-c-3.1.1.tar.gz'
tar xzf xerces-c-3.1.1.tar.gz
cd xerces-c-3.1.1
./configure --prefix=/home2/brainard/dependencies/xerces-c-3.1.1 2>&1 | tee log.configure
make 2>&1 | tee log.make
make install 2>&1 | tee log.install
ln -s /home2/brainard/dependencies/xerces-c-3.1.1 /home2/brainard/dependencies/xerces-c

Eigen

Mitsuba depends on the Eigen math library. We installed the Eigen 3 headers like so:

cd /home2/brainard/src
wget 'http://bitbucket.org/eigen/eigen/get/3.1.2.tar.gz'
mv 3.1.2.tar.gz eigen-3.1.2.tar.gz
tar xzf eigen-3.1.2.tar.gz
cp -r eigen-eigen-5097c01bcdc4 /home2/brainard/dependencies/eigen-3.1.2
ln -s /home2/brainard/dependencies/eigen-3.1.2 /home2/brainard/dependencies/eigen

GLEW

Mitsuba depends on the OpenGL Extension Wrangler Library. It also requires GLEW's "MX" support for multiple rendering contexts. We build GLEW with MX support like so:

cd /home2/brainard/src
wget 'http://sourceforge.net/projects/glew/files/glew/1.5.5/glew-1.5.5.tgz/download'
tar xzf glew-1.5.5.tgz
cd glew-1.5.5
export GLEW_DEST=/home2/brainard/dependencies/glew-1.5.5
make CFLAGS.EXTRA="-DGLEW_MX" LDFLAGS.GL="-lGLU -lGL -lXext -lX11" 2>&1 | tee log.make
make install CFLAGS.EXTRA="-DGLEW_MX" LDFLAGS.GL="-lGLU -lGL -lXext -lX11" 2>&1 | tee log.install
ln -s /home2/brainard/dependencies/glew-1.5.5 /home2/brainard/dependencies/glew

NVIDIA CG Toolkit

Mitsuba depends indirectly on the NVIDIA CG Toolkit, via the COLLADA DOM dependency below. The CG Toolkit might be unnecessary, depending on how COLLADA DOM is built. Nevertheless, we installed a pre-built version of the CG Toolkit like so:

cd /home2/brainard/src
wget 'http://developer.download.nvidia.com/cg/Cg_2.0/2.0.0012/Cg-2.0_Jan2008_x86_64.tar.gz'
tar xzf Cg-2.0_Jan2008_x86_64.tar.gz
mv usr /home2/brainard/dependencies/Cg-2.0
ln -s /home2/brainard/dependencies/Cg-2.0 /home2/brainard/dependencies/Cg

Note that the tar archive creates a folder called usr, which is not very descriptive.

COLLADA DOM

Mitsuba uses the COLLADA DOM to parse Collada scene files and import them into its native scene file format. Unfortunately, the COLLADA DOM build system is brittle and irritating. By default, it tries to build products that we don't need, and this introduces unneeded dependencies and other headaches. It is also difficult to reconfigure the build without editing the Make files.

First, we got the COLLADA DOM source:

cd /home2/brainard/src
wget 'http://sourceforge.net/projects/collada-dom/files/Collada%20DOM/Collada%20DOM%202.3/collada-dom-2.3.tgz/download'
tar xzf collada-dom-2.3.tgz
cd collada-dom-2.3

Then we edited the Make file dom/make/common.mk to avoid some unneeded dependencies. There should be a line that starts with ccFlags := near the top of the file. We changed to read:

ccFlags := -Wall -DNO_BOOST -DNO_ZAE

Then we proceeded to build the 2 COLLADA DOM components that Mitsuba needs: minizip and dom. This required some tiptoeing around the existing Make files.

cp Makefile.linux Makefile
make os=linux project=minizip parser=libxml -C dom 2>&1 | tee log.build-minizip
make os=linux project=dom parser=libxml -C dom 2>&1 | tee log.build-dom
cd dom
mkdir -p /home2/brainard/dependencies/collada-dom-2.3/include/colladadom
mkdir -p /home2/brainard/dependencies/collada-dom-2.3/lib
make install prefix=/home2/brainard/dependencies/collada-dom-2.3 2>&1 | tee log.install
cp build/linux-1.4/libminizip.* /home2/brainard/dependencies/collada-dom-2.3/lib
ln -sf /home2/brainard/dependencies/collada-dom-2.3 /home2/brainard/dependencies/collada-dom

GCC

Most of the time, we used the default system installation of the GNU Compiler Collection. But it turned out that Mitsuba needed an updated version of GCC in order to build correctly. We installed GCC 4.7.2 like so:

cd /home2/brainard/src
wget 'http://ftp.gnu.org/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.gz'
tar xzf gcc-4.7.2.tar.gz
cd gcc-4.7.2
./contrib/download_prerequisites
cd ..
mkdir gcc-4.7.2-build
cd gcc-4.7.2-build
$PWD/../gcc-4.7.2/configure --prefix=/home2/brainard/opt/gcc-4.7.2
make 2>&1 | tee log.build
make install 2>&1 | tee log.install

Note that this took a few hours to complete.

Qt

Mitsuba depends on the Qt framework. The Mitsuba build scripts explicitly check for Qt version 4. We found that Mitsuba uses specific Qt features that were introduced in Qt version 4.5, so we had to install an updated version. We installed Qt version 4.8.4 like so:

cd /home2/brainard/src
wget 'http://releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-4.8.4.tar.gz'
tar xzf qt-everywhere-opensource-src-4.8.4.tar.gz
cd qt-everywhere-opensource-src-4.8.4
./configure -prefix /home2/brainard/dependencies/qt-4.8.4 -fast -no-webkit -release -nomake examples -nomake demos -no-declarative -nomake docs 2>&1 | tee log.configure
make -j 4 2>&1 | tee log.make
make install 2>&1 | tee log.install
ln -s /home2/brainard/dependencies/qt-4.8.4 /home2/brainard/dependencies/qt

Note that this took about an hour, even though we omitted many unneeded Qt components.

Mitsuba

Finally, we were able to install Mitsuba. We had to reconfigure many parts of the Mitsuba build because we had so many custom-built dependencies. Fortunately, the Mitsuba build scripts are pretty flexible.

First, we got the Mitsuba version 0.4.4 source using Mercurial:

cd /home2/brainard/src
hg clone https://www.mitsuba-renderer.org/hg/mitsuba mitsuba
cd mitsuba
hg checkout v0.4.4

Then we chose the Mitsuba build configuration for Linux and GCC:

cp build/config-linux-gcc.py config.py

Then we edited our chosen config.py to agree with RenderToolbox3 and all of the dependencies we built above:

  • We defined the SPECTRUM_SAMPLES to be 31, to enable multi-spectral rendering.
  • We edited some existing lines of to use new values that agree with our custom dependencies.
  • We added several new LIBDIR lines that define library search paths for our custom dependencies.
CXX            = '/home2/brainard/opt/gcc-4.7.2/bin/g++'
CC             = '/home2/brainard/opt/gcc-4.7.2/bin/gcc'
CXXFLAGS       = [... '-DSPECTRUM_SAMPLES=31' ...]
EIGENINCLUDE   = ['/home2/brainard/dependencies/eigen']
XERCESINCLUDE  = ['/home2/brainard/dependencies/xerces-c/include']
XERCESLIBDIR   = ['/home2/brainard/dependencies/xerces-c/lib']
GLINCLUDE      = ['/home2/brainard/dependencies/glew/include']
GLLIBDIR       = ['/home2/brainard/dependencies/glew/lib64']
GLLIB          = ['GL', 'GLU', 'GLEW', 'X11']
BOOSTINCLUDE   = ['/home2/brainard/dependencies/boost/include']
BOOSTLIBDIR    = ['/home2/brainard/dependencies/boost/lib']
COLLADAINCLUDE = ['/home2/brainard/dependencies/collada-dom/include/colladadom', '/home2/brainard/dependencies/collada-dom/include/colladadom/1.4']
COLLADALIBDIR  = ['/home2/brainard/dependencies/collada-dom/lib']
COLLADALIB     = ['collada14dom', 'xml2']

We also edited include/mitsuba/core/spectrum.h to customize the range of wavelengths used for multi-spectral rendering:

#define SPECTRUM_MIN_WAVELENGTH   395
#define SPECTRUM_MAX_WAVELENGTH   705

Then we were able to build Mistuba with SCons and install it like so:

export PATH=/home2/brainard/dependencies/qt/bin:$PATH
export PKG_CONFIG_PATH=/home2/brainard/dependencies/qt/lib/pkgconfig:$PKG_CONFIG_PATH
/usr/global/python-2.7.3-intel/bin/python /home2/brainard/dependencies/scons/bin/scons -j 4 2>&1 | tee log.build
mkdir /home2/brainard/mitsuba
cp -r dist/* /home2/brainard/mitsuba
ln -s /home2/brainard/mitsuba/mitsuba /home2/brainard/bin
ln -s /home2/brainard/mitsuba/mtsimport /home2/brainard/bin
ln -s /home2/brainard/mitsuba/mtssrv /home2/brainard/bin
ln -s /home2/brainard/mitsuba/mtsutil /home2/brainard/bin
ln -s /home2/brainard/mitsuba/mtsgui /home2/brainard/bin

Note that we had to specify environment variables with the paths to our custom-build Qt framework.

Test Mitsuba

Before we could test Mitsuba, we had to set up the shell environment to locate the Mitsuba executables and several library dependencies:

export PATH=/home2/brainard/bin:$PATH
export LD_LIBRARY_PATH=/home2/brainard/opt/gcc-4.7.2/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home2/brainard/opt/gcc-4.7.2/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home2/brainard/dependencies/boost/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home2/brainard/dependencies/xerces-c/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home2/brainard/dependencies/glew/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home2/brainard/dependencies/collada-dom/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home2/brainard/mitsuba:$LD_LIBRARY_PATH

Now we were able to render one of the Mitsuba demo scenes:

mkdir /home2/brainard/test
cd /home2/brainard/test
wget 'http://www.mitsuba-renderer.org/scenes/cbox.zip'
unzip cbox.zip
cd cbox
mitsuba cbox.xml

We also tested Mitsuba's Collada scene file importer with one of the RenderToolbox3 example scenes:

cd /home2/brainard/test
mtsimport -r 320x240 /home2/brainard/toolboxes/RenderToolbox3/ExampleScenes/CoordinatesTest/CoordinatesTest.dae CoordinatesTest.xml
mitsuba CoordinatesTest.xml

Note that this produced many Mitsuba warnings about things like conservation of energy. But it demonstrated that the Collada importer was working!

To set up RenderToolbox3 and the example scenes, see Installing RenderToolbox3.

Clone this wiki locally