From BlenderWiki

Jump to: navigation, search

Here you find information about how to build Blender on modern machines and distributions.

Troubleshooting
In case you're trying to build on old distributions, chances are that your package manager doesn't provide a recent Python, Collada, etc: in those special cases please have a look at the troubleshooting page


To have latest Blender successfully running on Linux system you follow few simple steps.

This is not as hard as most people would think if you follow these instructions.

  1. Install needed package dependencies
  2. Download Blender source
  3. Compile Blender

Install the dependencies


Automatic dependencies installation

Exclamation mark.png
The preferred way to install dependencies under Linux is now to use the install_deps.sh script featured with Blender sources. It currently supports Debian (and derived), Fedora, Suse and Arch distributions. When using the install_deps.sh script, you are only required to install the following dependencies:
sudo apt-get update; sudo apt-get install git build-essential

Then, get the sources and run install_deps.sh as explained below.

To build with FFMPEG and Cycles enabled, various libraries are needed. These can be…

  • Installed through your distributions repositories.
  • Built manually.
  • Skipped (many dependencies are optional).
  • Managed by a script which checks for missing dependencies and installs them or compiles from sources.

The later solution is now the preferred one! Simply run:

cd ~/blender-git
./blender/build_files/build_environment/install_deps.sh

This script works for Debian/Redhat/SuSE based distributions, both 32 and 64 bits.

This scripts accepts some optional command lines arguments (use --help one to get an exhaustive list), among which:

--source <path>
Where to store downloaded sources for libraries we have to build (defaults to ~/src/blender-deps).
--install <path>
Where to install the libraries we have to build (defaults to /opt/lib).
--with-osl
Try to build OpenShadingLanguage. Note that this is still considered as experimental!
--skip-osl
Skip download and build OpenShadingLanguage.

Some commands in this script requires sudo, so you'll be likely asked couple of times for your password.

When the script finish installing/building all the packages, it'll print which parameters for CMake and SCons you should use to use compiled libraries.

Exclamation mark.png
If you have to compile your own boost libraries, you will have to tell Linux where to find them to get blender running. Just run the following commands as root user, from a terminal window:
echo "/opt/lib/boost/lib" > /etc/ld.so.conf.d/boost.conf
ldconfig

Manual dependencies installation

If you still want to use the “manual” way, you’ll need to install the following packages:

git, build-essential, libxi-dev, libsndfile1-dev, libopenexr-dev, 
libopenjpeg-dev, libpng12-dev, libjpeg-dev libopenal-dev, libalut-dev, python3.4-dev, 
libglu1-mesa-dev, libsdl-dev, libfreetype6-dev, libtiff4-dev, 
libavdevice-dev, libavformat-dev, libavutil-dev, libavcodec-dev, libswscale-dev, 
libx264-dev, libxvidcore4-dev, libmp3lame-dev, libspnav-dev, python3.4

As a final note, here are the key libraries that you may want to use with Blender:

Python (3.4)
Needed for interface scripts (building without Python is supported but not meant for general use).
Boost (min 1.49)
Necessary for Cycles, OSL, Audaspace, Internationalization…
OpenColorIO (min 1.0)
Necessary to handle color spaces.
OpenImageIO
Necessary for Cycles and OSL (min 1.1 in this case).
LLVM (min 3.0)
Necessary for OSL.
OpenShadingLanguage
Enable custom shaders under Cycles.
FFMPEG or libav (ffmpeg fork)
For handling most video formats/codecs.

Get the source

The first step is to get the latest Blender source code from blender.org's GIT repository.

Install GIT if you do not have it yet:

sudo apt-get update; sudo apt-get install git

Copy and paste the following instructions into a terminal window. The following commands create a blender-git folder in your home directory by downloading the latest source code commonly referred to as 'master'. An Internet connection is needed.

mkdir ~/blender-git
cd ~/blender-git
git clone http://git.blender.org/blender.git
cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master

If you want to update your git clone checkout to the latest source do (in ~/blender-git/blender/):

git pull --rebase
git submodule foreach git pull --rebase origin master

For additional information on using Git with Blender's sources, see: Tools/Git

Compile Blender with Scons

Do I need to install Scons?

No, currently scons is embedded in Blenders' source code.

How do I configure Scons?

By default, Scons will pickup the right configuration file depending on your operating system (Linux, Mac, Windows, etc...) and architecture (32/64bit, etc). In the Blender source (see #Get the source above) these files are located in blender/build_files/scons/config/:

aix4-config.py
darwin-config.py
irix6-config.py
linux2-config.py
linuxcross-config.py
openbsd3-config.py
sunos5-config.py
win32-mingw-config.py
win32-vc-config.py
win64-vc-config.py

For example, if you are working on a 32bit machine with Linux, Scons will pickup linux2-config.py to setup the Blender build.

If all the parameters in that file work for you, just start building Blender (see below).

user-config.py
If you don't have a system Python 3.2 and the package isn't available you may have to build your own and install to a custom location, or you want to build your own FFMPEG, or maybe you don't want to build the Game Engine, or the Blender Player, and so on.

In such a situation, you have to create a file called user-config.py in the root directory of the Blender source.

All the configuration in this file will override the ones in your Scons config file (in our example, linux2-config.py).


If you don't know what to put in user-config.py, please have a look at Scons default options to see their meaning.

In general, you have to copy some line from the default config file (in our example, linux2-config.py) and change the parameters that you want to override.

Building Blender

Note: since you intend to use Blender, you probably have a modern multi-core computer, so you should use the parallel build option to speed up the build. If you have a 2-core machine without hyperthreading, append -j 2 to the scons command. If you have a quad-core machine with hyperthreading, append -j 8 to the scons command.

cd ~/blender-git/blender
python scons/scons.py

At the end of the build process you will have a blender binary and a message...

Install file: "/home/myname/blender-git/blender/build/linux2/bin/blender" as
 "/home/myname/blender-git/blender/install/linux2/blender"
scons: done building targets.
*** Success ***

to run blender from the root path "~/blender-git/blender" you can create a symlink to the binary here... (the following example assumes you want the linux2 version)

cd ~/blender-git/blender
ln -s ../install/linux2/blender ./blender

Now you can run by typing (in ~/blender-git/blender)...

 ./blender

Rebuild after changing any files (in ~/blender-git/blender/ )...

 python scons/scons.py

If you have a multi-core CPU you can compile with multi-threading using the following:

 python scons/scons.py -j 2

The number stands for the number of jobs, so if you have a quad-core CPU you could put "-j 4".

Scons options

For completeness, please check these scons options.