Building the samples?


How do I build the C++ API sample?

I know nothing about cmake, but the obvious cmake . in samples/cpp/basic just produces errors about not being able to find APPLESEED(sic), FindImath.cmake or FindOpenEXR.cmake. Attempting to tell it where the include files and libraries are just produces more confusing errors. I had a look for documentation but didn’t see any.

Suggestions gratefully appreciated? I’ve been looking for a renderer I can use as a library from a C++ program for a while now…


Hey David,

appleseed is first a foremost a C++ library so it should fit your needs (all the apps we ship with it are using the official C++ API, nothing else).

A bit of foreword: appleseed is a large software project with many features, and thus many dependencies. Building appleseed or using it in a C++ project is unfortunately a non-trivial process, so it requires a bit of time and patience. We think it’s worth the effort, and many are doing it successfully. If it feels like too much, it’s OK and we won’t feel hurt :slight_smile:

Also, while some familiarity with CMake helps, we really ought to document the build process for the C++ samples. Let’s consider your question as an opportunity to make a first draft!

I’m assuming you are using Visual Studio 2015 (“vc14”) on Windows 64-bit. The steps below are easily adapted to other operating systems and versions of Visual Studio.

  1. Messages of the form

     By not providing "FindImath.cmake" in CMAKE_MODULE_PATH this project has
     asked CMake to find a package configuration file provided by "Imath", but
     CMake did not find one.

    indicate that CMake is not finding some files. This is our fault: we should include FindImath.cmake and FindOpenEXR.cmake in the share\ directory of appleseed packages, but currently we don’t.

    The first step is then to download these files and place them in share\ (right-click, Save link as):

  2. On Windows, we provide a set of prebuild binaries for most third party libraries: Download and unpack the archive that matches your version of Visual Studio, e.g. for Visual Studio 2015.

    We’ll suppose that you unpacked it in C:\dev\appleseed-deps, i.e. you should now have C:\dev\appleseed-deps\stage\vc14\.

  3. If you don’t have them already, you’ll also need to grab the Boost C++ Libraries. You’ll need Boost 1.55 if you’re using the prebuilt appleseed dependencies from the step above. You can download prebuilt binaries of Boost 1.55 here:

    We’ll suppose that you now have Boost 1.55 in C:\dev\boost_1_55_0.

  4. At this point you should have everything needed to build a C++ sample. Open a VS 2015 x64 Native Tools Command Prompt and navigate to the root directory of your appleseed installation.

  5. The standard practice with CMake is to build “out of sources”, so the next step is to create a build\ directory under samples\cpp\basic\:

     mkdir build
     cd build
  6. You can then invoke CMake to generate a Visual Studio solution:

     cmake -G "Visual Studio 14 2015 Win64" -DAPPLESEED_INCLUDE_DIR=..\..\..\..\include -DAPPLESEED_LIBRARY=..\..\..\..\lib\appleseed.lib -DBOOST_ROOT=C:\dev\boost_1_55_0 -DIMATH_INCLUDE_DIR=C:\dev\appleseed-deps\stage\vc14\ilmbase-release\include -DIMATH_MATH_LIBRARY=C:\dev\appleseed-deps\stage\vc14\ilmbase-release\lib\Imath-2_2.lib -DIMATH_IEX_LIBRARY=C:\dev\appleseed-deps\stage\vc14\ilmbase-release\lib\Iex-2_2.lib -DIMATH_HALF_LIBRARY=C:\dev\appleseed-deps\stage\vc14\ilmbase-release\lib\Half.lib -DOPENEXR_INCLUDE_DIR=C:\dev\appleseed-deps\stage\vc14\openexr-release\include -DOPENEXR_IMF_LIBRARY=C:\dev\appleseed-deps\stage\vc14\openexr-release\lib\IlmImf-2_2.lib -DOPENEXR_THREADS_LIBRARY=C:\dev\appleseed-deps\stage\vc14\ilmbase-release\lib\IlmThread-2_2.lib ..
  7. You can finally open the solution file (e.g. basic.sln) and hit Build.

That’s roughly it. Hopefully this is somewhat helpful. Please let me know if anything is unclear or doesn’t work as intended. In particular, I’m open to suggestions to improve this bit of documentation.


Sorry, I totally forgot to say! I’m on Linux.

The two *.cmake files almost did the trick — but I had to put them in share/cmake/Modules. My command line was:

$ mkdir build
$ cd build
$ cmake -DAPPLESEED_INCLUDE_DIR=../../../../include -DAPPLESEED_LIBRARY=../../../../lib/ ..

Running the makefile produced a million warnings about auto_ptr<> being deprecated and then failed with this:

/usr/bin/ld: CMakeFiles/basic.dir/basic.cpp.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/home/dg/src/appleseed/lib/ error adding symbols: DSO missing from command line

Boost is present and installed, it’s just refusing to link to it for some reason. I have no idea why.

So I tried hacking it:

$ g++ -g -O3 basic.cpp -I ../../../include/ ../../../lib/ ../../../lib/libboost_* ../../../lib/  ../../../lib/ ../../../lib/ -lpython2.7 ../../../lib/ ../../../lib/ ../../../lib/ ../../../lib/ ../../../lib/ ../../../lib/ 

This actually links and produces an executable. The bad news is that it doesn’t work, and crashes on startup. valgrind reports many buffer overruns accessing the MasterRenderer object allocated at line 301 of basic.cpp. This is almost certainly because my compiler has a different idea of how big the object is than the one used to produce your precompiled binaries does.

The real answer here is to build from source, but I was really hoping not to have to. I’ve had a quick go and unfortunately it doesn’t build out of the box.

Before I continue: the things I’m really interested in are:

  • procedural generation of geometry: I’m willing to create triangles and just hand the renderer a big mesh, but if you have an isosurface primitive that would be awesome;

  • procedural density functions for heterogeneous volumes (with Rayleigh scattering): I want to simulate planetary atmospheres, and so want to supply a callback which returns the atmospheric density in a particular location, and have the renderer do the rest.

Can Appleseed do this?

(Image attached, showing what I’m trying to do; it was rendered with a hacked copy of Povray. It’s showing the mountains of Jura, on the moon.)


Ahah, no worries, at least the Windows instructions are now written :slight_smile:

Yes, that’s the right place, sorry.

We can repro with our CI server and will disable this warning on gcc 6 in C++03 mode. Thanks.

Why does this say gcc48 if you’re building with gcc 6? Are binaries produced with gcc 4.8 and gcc 6 compatible?

Yes, the API let you do that of course.

We don’t support direct rendering of isosurfaces. Our plan is to allow custom intersectors at some point, it’s been asked by several people. It’s not a top priority as far as we’re concerned but we get around to implement it at some point. We’re also more than happy to assist anyone interested in adding this feature!

Unfortunately we don’t have any volume rendering yet. It’s very high on our informal roadmap but haven’t got around to start this project yet.

Very nice pic!


Why does this say gcc48 if you’re building with gcc 6? Are binaries produced with gcc 4.8 and gcc 6 compatible?

These are the binaries in the binary release and, well, apparently they’re not… I’ll admit to not actually spotting that in the paths.

Unfortunately we don’t have any volume rendering yet.


Not even homogeneous volumes? I’m sure I’ve seen pictures in the gallery with light rays through mist…