A note on compiling pbrt under Linux

August 27th, 2007 ~ Posted in: Programming

I spent about three hours on Friday night converging toward an install process for pbrt– the instructions on the CD that come with the book are outdated, and the forums on pbrt weren’t incredibly helpful. It turned out you have to install some auxiliary libraries first– this was the hard part: I found I had to delve into config.log to solve some problems. So, if you’re interested in compiling pbrt (I expect you probably found the site through Google, so welcome :) ), here’s the process that worked for me.

These directions assume bash is being used, and that your home directory is /home/gittens. Also, due to the use of the pre tag, some of the longer instructions may be partially occluded by other page elements. To see them in their entirety, copy and paste them into a text editor.

First get the IlmBase and OpenEXR libraries from openexr.com. Install IlmBase with

./configure --prefix=/home/gittens/usr
make; make install

then install OpenEXR with

LD_LIBRARY_PATH=/home/gittens/usr LDFLAGS=-lpthread ./configure --prefix=/home/gittens/usr
make; make install

Now you should be able to install pbrt directly (I’m assuming you have the other, more standard-issue libraries already installed, such as libtiff and zlib– if not, these libraries have been around so long that installing them to /home/gittens/usr should be a streamlined, painless process). There are a couple of changes to be made to the Makefile:

  • change the EXRINCLUDE, EXRLIBDIR variables to point to /home/gittens/usr/include/OpenEXR and /home/gittens/urs/lib.
  • If you want to instrument the code for debugging with, e.g. gdb, change the line OPT=-O2 to OPT=-g. pbrt will run slower, but being able to debug is necessary for some exercises in the book, and might be useful besides.

Then a simple make should suffice; the pbrt executable is in the bin directory.

If additionally, you want to use the tools in the pbrt distribution (most useful is the exrtotiff application, that converts pbrt’s native EXR output format to TIFF– you’ll probably want this unless you have a working EXR viewer lieing around, and how likely is that?), you need to edit the Makefile in that dir also:

  • Change the OPT to -O2 from -g (you’re not going to be debugging any of the tools, right?)
  • Change the CXXFLAGS from $(OPT) -I/sw/include -I$(EXRDIR)/include -I$(PBRTDIR)/core to -I/home/gittens/usr/include/OpenEXR -I$(PBRTDIR)/core
  • Change LDFLAGS = -L$(EXRDIR)/lib-linux to LDFLAGS=/home/gittens/usr/lib

To run pbrt, you’re going to need to make sure that the auxiliary libraries are in the linker’s search path and set up pbrt’s search path.
Write the following sh script into setupenv.sh:

export LD_LIBRARY_PATH=/home/gittens/usr/lib
export PBRT_SEARCHPATH=/home/gittens/work/pbrt-1.03/bin
export PATH=$PATH:PBRT_SEARCHPATH

and run this before you invoke pbrt.

This entry was posted on Monday, August 27th, 2007 at 12:20 pm and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply