mitsuba/doc/compiling.tex

364 lines
20 KiB
TeX
Raw Permalink Normal View History

\section{Compiling the renderer}
2011-07-06 23:52:02 +08:00
\label{sec:compiling}
To compile Mitsuba, you will need a recent C++ compiler (e.g. GCC 5.3+ or
Visual Studio 2017) and some additional libraries, which Mitsuba uses internally.
2011-05-30 18:17:46 +08:00
Builds on all supported platforms are done using a unified system
based on SCons\footnote{Mitsuba's configuration files are written for SCons 2.x. SCons 3 can be used by manually upgrading the relevant configuration files.} (\url{http://www.scons.org}), which is a Python-based
software construction tool. The exact process is different depending on
which operating system is used and will be explained in the following subsections.
\subsection{Common steps}
To get started, you will need to download a recent version of the Mitsuba source code. Before
doing this, ensure that you have read the licensing agreement
(\secref{license}), and that you abide by its contents. Note that, being a ``viral''
license, the GPL automatically applies to derivative work. Amongst other things, this
means that Mitsuba's source code is \emph{off-limits} to those who develop rendering
software not distributed under a compatible license.
Check that the Git (\url{https://git-scm.com/}) versioning system\footnote{On
Windows, you might want to use the convenient TortoiseGit shell extension
(\url{https://tortoisegit.org/}) to run the subsequent steps directly from the
Explorer.} is installed, which is required to fetch the most recent source code
release.
Begin by entering the following at the command prompt (or run an equivalent command from a graphical Git frontend):
\begin{shell}
$\texttt{\$}$ git clone https://github.com/mitsuba-renderer/mitsuba
\end{shell}
This should dowload a full copy of the main repository.
\subsubsection{Build configurations}
Common to all platforms is that a build configuration file must be selected. Several options are
available on each operating system:
\paragraph{Linux:}
On Linux, there are two supported configurations:
\begin{description}
\item[\code{build/config-linux-gcc.py}:] Optimized single precision GCC build. The resulting binaries include debug symbols for convenience, but these can only be used for relatively high-level debugging due to the enabled optimizations.
\item[\code{build/config-linux-gcc-debug.py}:] Non-optimized single precision GCC build with debug symbols. When compiled with this configuration, Mitsuba
will run extremely slowly. Its main use is to track down elusive bugs.
\end{description}
\paragraph{Windows:}
On Windows, builds can be performed using the Visual Studio 2017\footnote{No other Visual Studio versions are currently supported.}
compiler.
\begin{description}
\item[\code{build/config-win64-\{msvc2017, msvc2017-debug\}.py}:] Create 64 bit binaries using Microsoft Visual C++ version 2017.
The configurations with the suffix \code{-debug} will include debug symbols in all binaries, which run very slowly.
\end{description}
\paragraph{Mac OS:}
On Mac OS, builds can be performed using the XCode 8 \code{clang-llvm} toolchain.
It is possible to target MacOS 10.12 (Sierra) as the oldest supported operating system release.
XCode must be installed along with the supplementary Command Line Tools.
\begin{description}
\item[\code{config-macos-10.12-clang-x86\_64.py}:] Creates 64-bit binaries using the \code{clang-llvm} toolchain.
\end{description}
Note that the configuration files assume that XCode was
installed in the \code{/Applications} folder. They must be manually updated
when this is not the case.
\subsubsection{Selecting a configuration}
Having chosen a configuration, copy it to the main directory and rename it to \code{config.py}, e.g.:
\begin{shell}
$\texttt{\$}$ cp build/config-linux-gcc.py config.py
\end{shell}
2011-07-06 23:52:02 +08:00
\subsection{Compilation flags}
\label{sec:compiling-flags}
There are several flags that affect the behavior of Mitsuba and must be specified at compile time.
These usually don't need to be changed, but if you want to compile Mitsuba for spectral rendering, or
to use double precision for internal computations then the following may be useful. Otherwise, you may skip ahead to the subsection
that covers your operating system.
To change the compilation flags, open the \code{config.py} file that was just copied and look up the \code{CXXFLAG} parameter.
The following options are available:
\begin{description}
2011-05-30 18:17:46 +08:00
\item[\texttt{MTS\_DEBUG}] Enable assertions etc. Usually a good idea, and
enabled by default (even in release builds).
\item[\texttt{MTS\_KD\_DEBUG}] Enable additional checks in the kd-tree. This
is quite slow and mainly useful to track down bugs when they are suspected.
\item[\texttt{MTS\_KD\_CONSERVE\_MEMORY}] Use a more compact representation
for triangle geometry (at the cost of speed). This flag causes Mitsuba to use the somewhat slower
Moeller-Trumbore triangle intersection method instead of the default Wald
intersection test, which has an overhead of 48 bytes per triangle.
2010-10-14 05:20:20 +08:00
Off by default.
\item[\texttt{MTS\_SSE}]Activate optimized SSE routines. On by default.
\item[\texttt{MTS\_HAS\_COHERENT\_RT}]Include coherent ray tracing support (depends on \texttt{MTS\_SSE}). This flag is activated by default.
\item[\texttt{MTS\_DEBUG\_FP}]Generated NaNs and overflows will cause floating point exceptions, which can be caught in a debugger. This is slow and mainly meant as a debugging tool for developers. Off by default.
2011-07-06 23:52:02 +08:00
\item[\texttt{SPECTRUM\_SAMPLES=}$\langle ..\rangle$]This setting defines the number of spectral samples (in the 368-830 $nm$ range) that are used to render scenes. The default is 3 samples, in which case the renderer automatically turns into an RGB-based system. For high-quality spectral rendering, this should be set to 30 or higher.
Refer also to \secref{colorspaces}.
\item[\texttt{SINGLE\_PRECISION}] Do all computation in single precision. This is normally sufficient and therefore used as the default setting.
\item[\texttt{DOUBLE\_PRECISION}] Do all computation in double precision. This flag is incompatible with
\texttt{MTS\_SSE}, \texttt{MTS\_HAS\_COHERENT\_RT}, and \texttt{MTS\_DEBUG\_FP}.
\item[\texttt{MTS\_GUI\_SOFTWARE\_FALLBACK}]Causes the GUI to use a software
fallback instead of the hardware-accelerated realtime preview.
This is useful when the binary will be executed over a remote link using a
protocol such as RDP (which does not provide the requisite OpenGL features).
\end{description}
All of the default configurations files located in the \texttt{build} directory use the flags
\code{SINGLE\_PRECISION}, \code{SPECTRUM\_SAMPLES=3}, \code{MTS\_DEBUG}, \code{MTS\_SSE},
2011-05-30 18:17:46 +08:00
as well as \code{MTS\_HAS\_COHERENT\_RT}.
\subsection{Building on Debian or Ubuntu Linux}
2011-08-04 05:28:28 +08:00
\label{sec:compiling-ubuntu}
You'll first need to install a number of dependencies. It is assumed here that you are using a
recent version of Ubuntu Linux (Xenial Xerus / 16.04 LTS or later), hence some of the
package may be named differently if you are using Debian Linux or another Ubuntu version.
First, run
\begin{shell}
$\text{\$}$ sudo apt-get install build-essential scons git libpng12-dev
2013-11-06 04:40:48 +08:00
libjpeg-dev libilmbase-dev libxerces-c-dev libboost-all-dev libopenexr-dev
libglewmx-dev libxxf86vm-dev libeigen3-dev libfftw3-dev
\end{shell}
To get COLLADA support, you will also need to install the \texttt{collada-dom} packages:
\begin{shell}
$\text{\$}$ sudo apt-get install libcollada-dom-dev
\end{shell}
If you want to build the GUI as well, you will need to install the Qt 5 development libraries:
\begin{shell}
$\text{\$}$ sudo apt-get install qt5-default libqt5opengl5-dev libqt5xmlpatterns5-dev
\end{shell}
To start a regular build\footnote{If you have multiple Qt versions installed, you may need to select Qt 5 as the library version by running e.g.: \code{QT\_SELECT=qt5 scons} }, run
\begin{shell}
$\text{\$}$ scons
\end{shell}
inside the Mitsuba directory. In the case that you have multiple processors, you might want to parallelize the
build by appending \code{-j }\emph{core count} or \code{--parallelize} (uses all available cores) to the \code{scons} command.
If all goes well, SCons should finish successfully within a few minutes:
\begin{shell}
scons: $\texttt{done}$ building targets.
\end{shell}
To run the renderer from the command line, you first have to import it into your shell environment:
\begin{shell}
$\text{\$}$ source setpath.sh
\end{shell}
Having set up everything, you can now move on to \secref{basics}.
\subsubsection{Creating Debian or Ubuntu Linux packages}
The preferred way of redistributing executables on Debian or Ubuntu Linux is to create
\code{.deb} package files. To make custom Mitsuba packages, it is strongly recommended
that you work with a pristine installation of the target operating system\footnote{Several commercial graphics
drivers ``pollute'' the OpenGL setup so that the compiled Mitsuba binaries
can only be used on machines using the same drivers. For this reason, it is
2011-08-04 05:28:28 +08:00
better to work from a clean boostrapped install.}. This can be done as follows:
first, install \code{debootstrap} and download the most recent operating system release
to a subdirectory. The following example is based on Ubuntu 12.04 LTS (``Precise Pangolin''),
but the steps are almost identical for other versions of Ubuntu or Debian Linux.
2011-08-04 05:28:28 +08:00
\begin{shell}
$\text{\$}$ sudo apt-get install debootstrap
$\text{\$}$ sudo debootstrap --arch amd64 precise precise-pristine
2011-08-04 05:28:28 +08:00
\end{shell}
Next, \code{chroot} into the created directory, enable the \code{multiverse} package repository,
and install the necessary tools for creating package files:
\begin{shell}
$\text{\$}$ sudo chroot precise-pristine
$\text{\$}$ echo "deb http://archive.ubuntu.com/ubuntu precise universe" >> /etc/apt/sources.list
2011-08-04 05:28:28 +08:00
$\text{\$}$ apt-get update
$\text{\$}$ apt-get install debhelper dpkg-dev pkg-config
\end{shell}
Now, you should be able to set up the remaining dependencies as described in \secref{compiling-ubuntu}.
Once this is done, check out a copy of Mitsuba to the root directory of the \code{chroot} environment, e.g.
\begin{shell}
$\text{\$}$ git clone https://github.com/mitsuba-renderer/mitsuba
2011-08-04 05:28:28 +08:00
\end{shell}
To start the compilation process, enter
\begin{shell}
$\text{\$}$ cd mitsuba
$\text{\$}$ cp -R data/linux/debian debian
$\text{\$}$ dpkg-buildpackage -nc
\end{shell}
After everything has been built, you should find the created package files
in the root directory.
\subsubsection{Releasing Ubuntu packages}
To redistribute Ubuntu packages over the Internet or a local network, it is convenient to
2011-08-04 13:05:43 +08:00
put them into an \code{apt}-compatible repository. To prepare such a
repository, put the two \code{deb}-files built in the last section,
as well as the \code{collada-dom} \code{deb}-files into a public directory
made available by a HTTP server and inside it, run
2011-08-04 13:05:43 +08:00
\begin{shell}
2012-01-20 08:50:45 +08:00
path-to-htdocs$\text{\$}$ dpkg-scanpackages path/to/deb-directory /dev/null | gzip -9c > path/to/deb-directory/Packages.gz
2011-08-04 13:05:43 +08:00
\end{shell}
This will create a respository index file named \code{Packages.gz}.
Note that you must execute this command in the root directory of the
HTTP server's web directory and provide the relative path to the
package files -- otherwise, the index file will specify the wrong package
paths. Finally, the whole directory can be uploaded to some public location
2011-08-04 13:05:43 +08:00
and then referenced by placing a line following the pattern
\begin{shell}
deb http://<path-to-deb-directory> ./
2011-08-04 13:05:43 +08:00
\end{shell}
into the \code{/etc/apt/sources.list} file. This setup is convenient for
distributing a custom Mitsuba build to many Debian or Ubuntu machines running (e.g. to nodes in a rendering cluster).
\subsection{Building on Fedora Core}
You'll first need to install a number of dependencies. It is assumed here
that you are using FC27, hence some of the package may be named differently if you are
2011-08-16 16:35:34 +08:00
using another version.
First, run
\begin{shell}
$\text{\$}$ sudo yum install git gcc-c++ scons boost-devel qt5-devel qt5-qtxmlpatterns-devel OpenEXR-devel xerces-c-devel python-devel glew-devel libpng-devel libjpeg-devel collada-dom-devel eigen3-devel fftw3-devel
\end{shell}
2011-08-16 16:35:34 +08:00
Afterwards, simply run
2010-10-05 20:09:38 +08:00
\begin{shell}
$\text{\$}$ scons
\end{shell}
2011-08-16 16:35:34 +08:00
inside the Mitsuba directory. In the case that you have multiple processors, you might want to parallelize the build by appending \code{-j }\emph{core count} to the command.
2010-10-05 20:09:38 +08:00
If all goes well, SCons should finish successfully within a few minutes:
\begin{shell}
scons: $\texttt{done}$ building targets.
\end{shell}
To run the renderer from the command line, you first have to import it into your shell environment:
2010-10-05 20:09:38 +08:00
\begin{shell}
$\text{\$}$ source setpath.sh
2010-10-05 20:09:38 +08:00
\end{shell}
Having set up everything, you can now move on to \secref{basics}.
2011-08-16 16:35:34 +08:00
\subsubsection{Creating Fedora Core packages}
To create \code{RPM} packages, you will need to install the \code{RPM} development tools:
\begin{shell}
2012-09-29 08:55:01 +08:00
$\text{\$}$ sudo yum install rpmdevtools
2011-08-16 16:35:34 +08:00
\end{shell}
Once this is done, run the following command in your home directory:
\begin{shell}
$\text{\$}$ rpmdev-setuptree
\end{shell}
and create a Mitsuba source package in the appropriate directory:
\begin{shell}
$\text{\$}$ ln -s mitsuba mitsuba-$\code{\MitsubaVersion}$
$\text{\$}$ tar czvf rpmbuild/SOURCES/mitsuba-$\code{\MitsubaVersion}$.tar.gz mitsuba-$\code{\MitsubaVersion}$/.
\end{shell}
Finally, \code{rpmbuilder} can be invoked to create the package:
\begin{shell}
$\text{\$}$ rpmbuild -bb mitsuba-$\code{\MitsubaVersion}$/data/linux/fedora/mitsuba.spec
\end{shell}
After this command finishes, its output can be found in the directory \code{rpmbuild/RPMS}.
2010-10-05 20:09:38 +08:00
\subsection{Building on Arch Linux}
You'll first need to install a number of dependencies:
2011-08-17 09:29:56 +08:00
\begin{shell}
$\text{\$}$ sudo pacman -S gcc xerces-c glew openexr boost libpng libjpeg qt5 scons git python
2011-08-17 09:29:56 +08:00
\end{shell}
2011-08-20 15:36:40 +08:00
For COLLADA support, you will also have to install the \code{collada-dom}
library. For this, you can either install the binary package available on
the Mitsuba website, or you can compile it yourself using the \code{PKGBUILD}
supplied with Mitsuba, i.e.
2010-10-05 20:09:38 +08:00
\begin{shell}
2011-08-20 15:36:40 +08:00
$\text{\$}$ cd <some-temporary-directory>
$\text{\$}$ cp <path-to-mitsuba>/data/linux/arch/collada-dom/PKGBUILD .
$\text{\$}$ makepkg PKGBUILD
<..compiling..>
$\text{\$}$ sudo pacman -U <generated package file>
2010-10-05 20:09:38 +08:00
\end{shell}
2012-09-29 08:55:01 +08:00
Finally, Eigen 3 must be installed. Again, there is a binary package on the
Mitsuba website and the corresponding \code{PKGBUILD} can be obtained here:
\url{http://aur.archlinux.org/packages.php?ID=47884}.
2011-08-20 15:36:40 +08:00
Once all dependencies are taken care of, simply run
\begin{shell}
2011-08-20 15:36:40 +08:00
$\text{\$}$ scons
\end{shell}
inside the Mitsuba directory. In the case that you have multiple processors, you might want to parallelize the build by appending \code{-j }\emph{core count} or \code{--parallelize} (uses all available cores) to the command.
2011-08-20 15:36:40 +08:00
If all goes well, SCons should finish successfully within a few minutes:
\begin{shell}
2011-08-20 15:36:40 +08:00
scons: $\texttt{done}$ building targets.
\end{shell}
To run the renderer from the command line, you first have to import it into your shell environment:
\begin{shell}
$\text{\$}$ source setpath.sh
\end{shell}
2011-08-20 15:36:40 +08:00
Having set up everything, you can now move on to \secref{basics}.
\subsubsection{Creating Arch Linux packages}
Mitsuba ships with a \code{PKGBUILD} file, which automatically builds
a package from the most recent repository version:
\begin{shell}
2011-08-20 15:36:40 +08:00
$\text{\$}$ makepkg data/linux/arch/mitsuba/PKGBUILD
\end{shell}
% This is currently outdated
%\subsection{Compiling on Gentoo Linux}
%Simon Haegler has contributed a Gentoo \code{ebuild} script that can be used to Mitsuba.
%It can be found inside the user repository \code{git://git.overlays.gentoo.org/user/mistafunk.git}
%and is located at \code{media-gfx/mitsuba/mitsuba-0.3.0.ebuild}.
2011-11-29 13:53:57 +08:00
\subsection{Building on Windows}
Compiling Mitsuba's dependencies on Windows is a laborious process; for convenience, there
is a repository that provides them in precompiled form. To use this repository, clone it
using Git and rename the directory so that it forms the \code{dependencies} subdirectory
inside the main Mitsuba directory, i.e. run something like
\begin{shell}
C:\>cd mitsuba
C:\mitsuba\>git clone https://github.com/mitsuba-renderer/dependencies_win64 dependencies
\end{shell}
There are a few other things that need to be set up: make sure that your
installation of Visual Studio is up to date, since Mitsuba binaries created with versions prior to 2017 will not link or crash.
2011-10-28 00:51:37 +08:00
Next, you will need to install Python 2.7.x
(\url{www.python.org}) and SCons\footnote{Note that on some Windows machines, the SCons
installer generates a warning about not finding Python in the registry. In this case, you
can instead run \code{python setup.py install} within the source release of SCons, or install a 32-bit version of Python.}
(\url{http://www.scons.org}, any 2.x version will do) and ensure that they are contained in the \code{\%PATH\%}
environment variable so that entering \code{scons} on the command prompt (\code{cmd.exe})
2011-08-23 01:07:28 +08:00
launches the build system.
2011-06-05 23:26:30 +08:00
Having installed all dependencies, run the ``x64 Native Tools Command Prompt
for VS \emph{2017}'' from the Start Menu,
navigate to the Mitsuba directory, and simply run
2011-06-01 09:06:25 +08:00
\begin{shell}
C:\mitsuba\>scons
2011-06-01 09:06:25 +08:00
\end{shell}
In the case that you have multiple processors, you might want to parallelize the build by appending the option \code{-j }\emph{core count} or \code{--parallelize} (uses all available cores) to the \code{scons} command.
2010-08-11 06:38:22 +08:00
If all goes well, the build process will finish successfully after a few
minutes. \emph{Note} that in comparison to the other platforms, you don't have to run the \code{setpath.sh} script at this point.
2011-10-28 00:57:33 +08:00
All binaries are automatically copied into the \code{dist} directory, and they should be executed directly from there.
\subsubsection{Integration with the Visual Studio interface}
Basic Visual Studio 2017 integration with support for code completion
exists for those who develop Mitsuba code on Windows.
To use the supplied projects, simply double-click on one of the two files \code{build/mitsuba-msvc2017.sln}
and \code{build/mitsuba-msvc2017.vcxproj}. These Visual Studio projects still internally
use the SCons-based build system to compile Mitsuba; whatever
2011-06-01 09:26:23 +08:00
build configuration is selected within Visual Studio will be used to pick a matching
configuration file from the \texttt{build} directory.
\subsection{Building on Mac OS X}
\vspace{-5mm}
\remarks{
\item Unfortunately, OpenMP is not available when compiling
using the regular \code{clang} toolchain.
This will cause the following parts of Mitsuba
to run single-threaded: bitmap resampling (i.e. MIP map generation),
blue noise point generation in the \pluginref{dipole}
plugin, as well as the \pluginref{ppm} and \pluginref{sppm} plugins.
\item The pre-compiled dependencies do not include the \code{collada-dom}
library.
It is possible to install it with Homebrew (\url{https://brew.sh/},
then run \code{brew install collada-dom})
and then adding the \code{include} folder paths and library name to \code{config.py}.
By default, they should look like this:
\begin{python}
COLLADAINCLUDE = ['/usr/local/include/collada-dom2.4', '/usr/local/include/collada-dom2.4/1.4']
COLLADALIBDIR = ['/usr/local/Cellar/collada-dom/2.4.4/lib']
COLLADALIB = ['collada-dom2.4-dp']
\end{python}
\item To build the Mitsuba GUI, you need a working Qt 5 installation.
You may install it with Homebrew (\code{brew install qt}) or by downloading
the appropriate package from \url{https://qt.io}.
}
Compiling Mitsuba's dependencies on Mac OS is a laborious process; for convenience, there
is a repository that provides them in precompiled form. To use this repository, clone it
using Git and rename the directory so that it forms the \code{dependencies} subdirectory
inside the main Mitsuba directory, i.e. run something like
\begin{shell}
$\text{\$}$ cd mitsuba
$\text{\$}$ git clone https://github.com/mitsuba-renderer/dependencies_macos dependencies
\end{shell}
You will also need to install SCons (>2.0.0, available at \code{www.scons.org}) and
a recent release of XCode, including its command-line compilation tools. Next, run
\begin{shell}
$\text{\$}$ scons
\end{shell}
inside the Mitsuba directory. In the case that you have multiple processors, you might want to parallelize the build by appending \code{-j }\emph{core count} or \code{--parallelize} (uses all available cores) to the command.
If all goes well, SCons should finish successfully within a few minutes:
\begin{shell}
scons: $\texttt{done}$ building targets.
\end{shell}
To run the renderer from the command line, you first have to import it into your shell environment:
\begin{shell}
$\text{\$}$ source setpath.sh
\end{shell}