Skip to content

Building appleseed on Linux

Abhiram edited this page Aug 1, 2023 · 159 revisions

Prerequisites

Tools

gcc

Red Hat Developer Toolset 6 gcc is currently the officially supported version to build appleseed. You may however use a more recent version of gcc (6.x, 7.x, 8.x or 9.x) to compile appleseed against the precompiled dependencies. While this will usually work, we do not officially support this scenario.

Prebuilt dependencies

appleseed has many dependencies, some of them not usually included in common Linux distributions. The recommended method to build appleseed on Linux is to use precompiled dependencies. This is the method documented here.

There is a repository containing most of appleseed dependencies compiled with gcc 6.3 here: https://github.com/appleseedhq/linux-deps

They are the same dependencies used to build appleseed on Travis, our continuous integration server.

zlib, libnsl

You must also have the zlib and zlib-devel packages installed (they are usually already installed). On older Ubuntu versions, you can install these packages with the following commands:

sudo apt install zlib
sudo apt install zlib-devel

and on newer Ubuntu releases (18.04 etc.) with:

sudo apt install zlib1g
sudo apt install zlib1g-dev or sudo apt-get install zlib1g-dev

On recent Fedora versions you will need to install libnsl.so.1 via:

dnf install libnsl

libnsl, the legacy support library for NIS services, is required by the Xerces-C++ XML parser. It was formerly part of glibc but is now standalone and therefore no longer installed by default.

Qt 5

Qt 5 is required to build appleseed.studio, the graphical user interface to appleseed.

appleseed will not build using Qt 4.x, you DO need a recent 5.x version of Qt.

Most Linux distributions allow to download the Qt 5 SDK from their package repositories. On Ubuntu, the Qt 5 SDK can be installed with the following command:

sudo apt install qtbase5-dev

For Fedora the respective command is:

sudo dnf install qt5-qtbase-devel

Alternatively, you may download the packages from the official Qt website Qt Online Installer for Linux (64-bit). Once the .run file is downloaded, give it execute permissions, e.g.

chmod +x qt-unified-linux-x64-3.1.1-online.run

and execute it, e.g.

./qt-unified-linux-x64-3.1.1-online.run

Python 2.7

A system installation of Python 2.7 is necessary to build appleseed studio. Current Fedora 33 does not come anymore with Python 2.7 installed by default. It needs to be added manually via dnf:

sudo dnf install python2.7

Building appleseed

  1. Download the prebuilt dependencies package and unpack it:
    https://github.com/appleseedhq/linux-deps/releases/download/v2.1.1/appleseed-deps-shared-2.1.1.tgz

  2. Clone the appleseed repository:

    git clone https://github.com/appleseedhq/appleseed.git
    cd appleseed
    
  3. Prepare the environment (make sure to replace placeholder paths):

    export APPLESEED_DEPENDENCIES=/path/to/prebuilt-linux-deps
    export CMAKE_INCLUDE_PATH=$APPLESEED_DEPENDENCIES/include
    export CMAKE_LIBRARY_PATH=$APPLESEED_DEPENDENCIES/lib
    export LD_LIBRARY_PATH=$APPLESEED_DEPENDENCIES/lib
    
  4. Build appleseed:

    mkdir build
    cd build
    cmake \
      -Wno-dev \
      -DCMAKE_PREFIX_PATH=/usr/include/x86_64-linux-gnu/qt5 \
      -DWITH_EMBREE=ON \
      -DUSE_SSE42=ON \
      -DUSE_STATIC_BOOST=OFF \
      -DBoost_INCLUDE_DIR=$APPLESEED_DEPENDENCIES/include/boost_1_61_0 \
      -DBOOST_LIBRARYDIR=$APPLESEED_DEPENDENCIES/lib/ \
      -DBoost_NO_SYSTEM_PATHS=ON \
      -DBoost_ATOMIC_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_atomic-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_CHRONO_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_chrono-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_DATE_TIME_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_date_time-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_FILESYSTEM_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_filesystem-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_PYTHON_LIBRARY=$APPLESEED_DEPENDENCIES/lib/libboost_python-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_PYTHON_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_python-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_REGEX_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_regex-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_SYSTEM_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_system-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_THREAD_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_thread-gcc63-mt-1_61.so.1.61.0 \
      -DBoost_WAVE_LIBRARY_RELEASE=$APPLESEED_DEPENDENCIES/lib/libboost_wave-gcc63-mt-1_61.so.1.61.0 \
      -DEMBREE_INCLUDE_DIR=$APPLESEED_DEPENDENCIES/include \
      -DEMBREE_LIBRARY=$APPLESEED_DEPENDENCIES/lib/libembree3.so \
      -DLZ4_INCLUDE_DIR=$APPLESEED_DEPENDENCIES/include \
      -DLZ4_LIBRARY=$APPLESEED_DEPENDENCIES/lib/liblz4.so \
      -DOPENIMAGEIO_OIIOTOOL=$APPLESEED_DEPENDENCIES/bin/oiiotool \
      -DOPENIMAGEIO_IDIFF=$APPLESEED_DEPENDENCIES/bin/idiff \
      -DOSL_COMPILER=$APPLESEED_DEPENDENCIES/bin/oslc \
      -DOSL_MAKETX=$APPLESEED_DEPENDENCIES/bin/maketx \
      -DOSL_QUERY_INFO=$APPLESEED_DEPENDENCIES/bin/oslinfo \
      ..
    make
    

You can also use make -j$(nproc) to run multiple jobs parallely and speed up the build process

After you run the CMake command if several warnings are raised, Include both of these lines in the CMakeLists.txt file present in the root directory of appleseed. Add these lines right below the cmake_minimum_required command

set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)

This will install appleseed binaries under the sandbox/bin/Ship/ directory.

If you are not using the compiler in Red Hat Developer Toolset 6, add the following line to the CMake command:

-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0

Depending on the Linux distribution, you may have to change the -DCMAKE_PREFIX_PATH entry above to point to the correct location of the Qt 5 include directory. For Fedora users this would be:

-DCMAKE_PREFIX_PATH=/usr/include/qt5 \

A note regarding compiler warnings

The default build configuration (or build type in CMake's terminology) is Ship (check Build Configurations for details). In Ship and Profile configurations, warnings emitted by the compiler don't cause builds to fail.

However, if you decide to build appleseed in Debug or Release configurations, any compiler warning will be treated as an error and will cause builds to fail.

We always make sure that the master branch of appleseed builds cleanly (without any warning) on all platforms and with all supported compiler and compiler versions. However your compiler may emit new warnings which will cause builds to fail.

Ideally, we would appreciate that you investigate the cause of these warnings and submit a pull request that fix them. Alternatively, you can add -DWARNINGS_AS_ERRORS=OFF to CMake's command line, then run make again. Warnings will still be emitted by the compiler but they won't cause builds to fail anymore.

Building appleseed with static libraries

In some very rare cases you may need to use static libraries instead of the shared ones. If you are unsure about which libraries to take, use the shared ones.

Running appleseed

appleseed binaries, appleseed.studio in particular, need an "environment" with a specific directory structure and a number of support files in order to run properly. We call this environment the sandbox. The appleseed repository comes with a fully configured sandbox in the sandbox/ directory.

When appleseed is built, binaries get automatically deployed to sandbox/bin/<config> where <config> is the build configuration you selected with CMake's CMAKE_BUILD_TYPE option.

In addition to the sandbox, developer builds of appleseed.studio need to find the standard library of a Python 2.7 installation for the embedded Python 2.7 to function properly. The location of the system Python installation varies among the Linux distributions. Python uses several environment variables, among them PYTHONHOME, to find the executables and modules. To set this variable, type

export PYTHONHOME=/usr

You should now be able to run appleseed.studio: navigate to sandbox/bin/<config> (e.g. sandbox/bin/Ship) and type

./appleseed.studio

Note that official builds of appleseed ship with a Python 2.7 standard library so they don't need one to exist on the user's system.

Clone this wiki locally