Building Blender on Linux¶
These are instructions to build Blender on common Linux distributions.
To exactly match the official release build setup, see the Rocky Linux 8.
Quick Setup¶
The following instructions will create a Blender build in a
blender-git
folder in your home directory.
Install Initial Packages¶
Ensure Python3, Git and Git LFS are installed.
Download Sources¶
Download the latest source code from projects.blender.org.
Install Basic Building Environment¶
Run this command to install basic building dependencies.
Some commands in this script requires sudo
, so you'll be likely be asked
for your password.
Run this command to install basic building dependencies.
Some commands in this script requires sudo
, so you'll be likely be asked
for your password.
Alternatively, you can also install all basic dependencies manually with the package manager.
Run this command to install basic building dependencies.
Some commands in this script requires sudo
, so you'll be likely be asked
for your password.
Alternatively, you can also install all basic dependencies manually with the package manager.
sudo dnf update
sudo dnf install gcc gcc-c++ git git-lfs subversion make cmake mesa-libGL-devel mesa-libEGL-devel libX11-devel libXxf86vm-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel libstdc++-static
sudo dnf install wayland-devel wayland-protocols-devel libxkbcommon-devel dbus-devel kernel-headers
Run this command to install basic building dependencies.
Some commands in this script requires sudo
, so you'll be likely be asked
for your password.
Alternatively, you can also install all basic dependencies manually with the package manager.
You need to install all the basic dependencies manually, using packages specific to your Linux distribution:
gcc g++ make cmake
git git-lfs subversion
libx11-dev libxxf86vm-dev libxcursor-dev libxi-dev libxrandr-dev libxinerama-dev libegl-dev
libwayland-dev wayland-protocols libxkbcommon-dev libdbus-1-dev linux-libc-dev
Running this command will also give you the list of required dependencies.
Download Libraries¶
For Intel and AMD Linux systems, we recommend using precompiled libraries. These are the quickest way to get a feature complete Blender build and can be downloaded as follows.
These libraries are built on Rocky8 for VFX reference platform compatibility, but they work fine on other Linux distributions.
To use system packages, see Advanced Setup.
Update and Build¶
Get latest source code and add-ons, and build. These commands can be used for the first build, and repeated whenever you want to update to the latest version.
After the build finished, you will find blender ready to run in
~/blender-git/build_linux/bin
.
If building fails after an update, it sometimes helps to remove the
~/blender-git/build_linux
folder to get a completely clean build.
Branches¶
With the quick setup instructions the main
branch will be built by
default, which contains the latest Blender version under development.
To build another branch or a pull request,
first checkout the branch and then run make update
to update the add-ons,
libraries and tests to match.
Depending on how big the changes are compared to the main
branch, it
may be necessary to remove the build folder
~/blender-git/build_linux
. Otherwise the build folder may still
refer to libraries from another branch.
Advanced Setup¶
System Packages¶
When not using precompiled libraries, the preferred way to install
dependencies under Linux is to use the install_linux_packages.py
script in the Blender sources. It will try to install system packages
for all known dependencies, required or optional.
It currently supports Debian (and derivatives like Ubuntu), Fedora, SUSE and Arch distributions. It is executed as follows.
Some commands in this script requires sudo
, so you'll be likely be asked
for your password.
For unrecognized distributions, it will only print a list of the dependencies.
Conflicts with Precompiled Libraries
In case both precompiled and system libraries are present, by default CMake will use the pre-compiled ones.
To force it to ignore the precompiled libraries and search for system
ones, CMake WITH_LIBS_PRECOMPILED
option must be disabled.
Building Dependencies from Source¶
Instead of using precompiled libraries or system packages, it is possible to build all libraries from source.
This is not recommended for most users, as this is mostly used by Blender platform maintainers and not well tested on other systems. You may need to dig into the CMake code yourself to solve build problems.
The make deps system
will build libraries from source and put them in ../lib/linux_x86_64_glibc_228
.
The Blender build system automatically picks up libraries from this location
over precompiled libraries.
Portable Builds¶
To make a build that works on other computers, in general you need to:
- Build on an older Linux distribution version. That is because you need to build with a glibc version that is equal or lower than the systems the build needs to run on. Rocky Linux 8 is used for official releases.
- Use precompiled libraries or libraries built from source. System packages can not be used, as those vary between Linux distributions and versions.
Manual CMake Setup¶
Instructions
If you want to have more control over your build configuration or have multiple build directories for a single source directory. You can follow these steps.
Typically useful for developers, who build frequently.
CMake Setup¶
Now you have to choose a location for CMake build files, currently in-source builds in Blender aren't supported.
Out-of-source build
By doing an "out-of-source"
build
you create a CMake's directory aside from ~/blender-git/blender
, for
example ~/blender-git/build
:
This will generate makefiles in the build directory
(~/blender-git/build
).
Important
As said above, in-source-builds where you build blender from the
source code directory are not supported.
If CMake finds a CMakeCache.txt
in the source code directory, it
uses that instead of using ~/blender-git/build/CMakeCache.txt
.
If you have tried to do an in-source build, you should remove any CMakeCache.txt from the source code directory before actually running the out-of-source build:
Building Blender¶
After changes have been done and you have generated the makefiles, you can compile using the make command inside the build directory:
Also notice the install target is used, this will copy scripts and
documentation into ~/blender-git/build/bin
For future builds you can simply update the repository and re-run make.
Build Options¶
By default Blender builds will be similar to official releases. Many Build Options are available for debugging, faster builds, and to enable or disable various features.
System Installation¶
Portable installation is the default where scripts and data files will
be copied into the build ~/blender-git/build/bin
directory and can
be moved to other systems easily.
To install Blender into the system directories, a system installation
can be used instead. Disable WITH_INSTALL_PORTABLE
to install into
CMAKE_INSTALL_PREFIX
which uses a typical Unix
FHS
layout: bin/, share/blender/, man/ etc.
Optimize Rebuilds¶
Instructions
Now that you can build Blender and run Blender, there are changes you can make which greatly increase the speed of build times.
Use one of the CMake configuration editors (ccmake or cmake-gui), see Editing CMake Options
For really fast rebuilds you can disable Every option with the
WITH_
prefix, except for WITH_PYTHON
which is needed for the UI.
This speeds up linking and gives a smaller binary.
Remove the files created by make install
since they will become
stale. However, Blender still needs to be able to find its scripts or
you will have a very minimalist looking interface. This can be solved by
linking the source directory to your Blender binary path so copying
isn't needed and scripts are always up to date.
For convenient access, create this symlink to run blender from the source directory:
You can add any files created this way to
~/blender-git/blender/.git/info/exclude
so they won't count as
untracked files for git. Add your local files here, instead of in
.gitignore, because .gitignore is also committed and will affect
everyone else.