Building Blender/Linux/Generic Distro
< Building Blender | Linux(Redirected from Dev:Doc/Building Blender/Linux/Generic Distro/CMake)
The following instructions will create a Blender build in a blender-git folder in your home directory.
Install these or equivalent packages for your specific Linux distribution:
gcc g++ make cmake git subversion libx11-dev libxxf86vm-dev libxcursor-dev libxi-dev libxrandr-dev libxinerama-dev libglew-dev
Download the latest source code from the git.blender.org.
mkdir ~/blender-git cd ~/blender-git git clone https://git.blender.org/blender.git
For additional information on using Git with Blender's sources, see Git Usage.
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 CentOS 7 for VFX reference platform compatibility, but they work fine on other Linux distributions.
mkdir ~/blender-git/lib cd ~/blender-git/lib svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/linux_centos7_x86_64
For other systems or 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.
cd ~/blender-git/blender make update make
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.
Automatic Dependency Installation
When not using precompiled libraries, the preferred way to install dependencies under Linux is to use the
script in the Blender sources. It will install system packages where possible, and if needed can build some libraries from source.
It currently supports Debian (and derivatives), Ubuntu, Fedora, Suse and Arch distributions. It is executed as follows.
cd ~/blender-git ./blender/build_files/build_environment/install_deps.sh
Some commands in this script requires sudo, so you'll be likely be asked for your password. When the script finishes installing/building all the packages, it prints the instructions to configure the build with the required CMake parameters.
For other distributions, it can:
- Print the list of all main dependencies needed to build Blender (
- Attempt to build main 'big' libraries you cannot easily install from packages (
--helpof the script for details).
Important It might be required to re-run install-depsh.sh once in a while, as Blender updates its dependencies. You will typically want to try this when you have build errors after updating the sources.
This scripts accepts some optional command lines arguments (use
--help one to get an exhaustive list), among which:
- Where to store downloaded sources for libraries we have to build (defaults to
- Where to install the libraries we have to build (defaults to
- Include some extra libraries that are by default not considered mandatory (main effect of this one is building OpenCollada).
The above instructions install packages through the system package manager. This makes it possible to share packages between Blender and other software, however the resulting builds will generally not work on other computers.
When using the precompiled libraries, builds are portable and can be shared with others. These libraries are built from source, and this system can also be used to create your own portable libraries.
Running make deps will build libraries in ../lib/linux_x86_64, which will be automatically picked up when building Blender itself.
Besides the libraries, the glibc version of the system affects portability. Builds will only run on Linuxes with the same or higher glibc version. Official builds are made with RHEL 7 and glibc 2.17.
Manual CMake Setup
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.
Now you have to choose a location for CMake build files, currently in-source builds in Blender aren't supported.
By doing an "out-of-source" build you create a CMake's directory aside from
~/blender-git/blender, for example
mkdir ~/blender-git/build cd ~/blender-git/build cmake ../blender
This will generate makefiles in the build directory (
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
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:
After changes have been done and you have generated the makefiles, you can compile using the make command inside the build directory:
cd ~/blender-git/build make make install
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.
cd ~/blender-git/blender make update cd ~/blender-git/build make make install
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.
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.
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 Parameters
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.
rm -r ~/blender-git/build/bin/*.* ln -s ~/blender-git/blender/release ~/blender-git/build/bin/
For convenient access, create this symlink to run blender from the source directory:
ln -s ~/blender-git/build/bin/blender ~/blender-git/blender/blender.bin
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.