Blender在Ubuntu上的编译

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 required package dependencies.
  2. Download Blender source.
  3. Compile Blender.

Get the source

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

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-gitcd ~/blender-gitgit clone http://git.blender.org/blender.gitcd blendergit submodule update --init --recursivegit submodule foreach git checkout mastergit 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 --rebasegit submodule foreach git pull --rebase origin master

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

Install the dependencies

Automatic dependencies installation

The preferred way to install dependencies under Linux is now to use the install_deps.shscript 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.

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

To manually install Blender‘s dependancy packages:

sudo apt-get update; sudo apt-get install git build-essential  libxi-dev libsndfile1-dev  libpng12-dev libjpeg-dev libfftw3-dev  libopenexr-dev libopenjpeg-dev  libopenal-dev libalut-dev libvorbis-dev  libglu1-mesa-dev libsdl1.2-dev libfreetype6-dev  libtiff4-dev libavdevice-dev  libavformat-dev libavutil-dev libavcodec-dev libjack-dev  libswscale-dev libx264-dev libmp3lame-dev python3.4-dev  libspnav-dev libtheora-dev libjack-dev libglew1.6-dev

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.

Compile Blender with CMake

Installing CMake

From within your package manager, install:

  • cmake
  • a cmake‘s configuration tool like
    • ccmake (text based interface) or,
    • cmake-gui (GUI configuration tool).

Automatic CMake Setup

If you‘re not interested in manually setting up CMake build directory, configuring, building and installing in separate steps, we provide a convenience makefile in blenders source directory which sets up cmake for you.

cd ~/blender-git/blendermake

Updating blender is as simple as:

cd ~/blender-git/blendergit pull --rebasegit submodule foreach git pull --rebase origin mastermake

Once the build finishes you‘ll get a message like..

blender installed, run from: /home/me/blender-git/build_linux/bin/blender

There are some pre-defined build targets:

  • make - some are turned off by default because they can be difficult to correctly configure for newer developers and aren‘t essential to use & develop Blender in most cases.
  • make lite - the quickest way to get a Blender build up & running, can also help to avoid installing a lot of dependencies if you don‘t need video-codecs, physics-sim & cycles rendering.
  • make full - this makes a complete build with all options enabled, matching the releases on blender.org.

For a full list of the optional targets type...

make help

Manual CMake Setup

If you want to have more control over your build and have configuration, building and installation as separate steps or have multiple build directories for a single source dir. You can follow these steps.

Preparing CMake‘s directory

Let‘s suppose that you‘ve checked out Blender‘s source in the folder ~/blender-git/blender.

Please note that in some cases the "blender" directory may have a different name. Some branches are modified copies of the trunk/blender directory and are named e.g. soc-2009-name_of_participant.

Now you have to choose a location for CMake build files. In CMake you could do an "in-source" build or an "out-of-source" build, but currently in-source builds in Blender are not allowed.

Out-of-source build

By doing an "out-of-source" build you create a CMake‘s folder aside from ~/blender-git/blender, for example ~/blender-git/build:

mkdir ~/blender-git/buildcd ~/blender-git/build
cmake ../blender

This will generate makefiles in the build folder (~/blender-git/build).


Warning

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:

rm -f ~/blender-git/blender/CMakeCache.txt

Editing CMake‘s Parameters

Note that CMake should detect correct parameters so you shouldn‘t need change defaults to simply to compile blender, this is only if you want to change defaults, make a debug build, disable features etc,
so you may want to skip this section for now and come back to it later if you want to make adjustments.

You can modify the build parameters in different ways:

  • editing ~/blender-git/build/CMakeCache.txt file in a text editor
  • using cmake-gui if your distro supports it
  • cmake-gui ../blender
  • Opens a graphical interface where you can easily change parameters and re-configure things.
  • using ccmake tool, with
  • ccmake ../blender
  • Opens a text interface where you can easily change parameters and re-configure things.
  • cmake parameters can also be easily set on the command line, for eg.
cmake ../blender     -DCMAKE_INSTALL_PREFIX=/opt/blender     -DWITH_INSTALL_PORTABLE=OFF     -DWITH_BUILDINFO=OFF     -DWITH_GAMEENGINE=OFF
  • These commands are exactly those found in ~/blender-git/build/CMakeCache.txt so you can copy commands from there and use them in the command line without running ccmake.

Screenshot from cmake-gui, qt based gui for cmake


Screenshot from ccmake, curse-based gui for cmake

Building Blender

After changes have been done and you have generated the makefiles, you can compile using the make command inside the build folder:

cd ~/blender-git/buildmakemake install

Parallel Builds
For multi-core / multi processor systems you can build much faster by passing the jobs argument to make: -j(1+number_of_cores).

For example put "-j3" if you have a dual-core or "-j5" if you have a quad-core.
For Shell-scripts use GNU-Syntax: expr `nproc` + 1 or Bash-Syntax: $((`nproc`+1))

If it‘s still not using all your CPU power, leave out the number: "-j" to spawn as many as possible build processes (usually 64).
Note that it may build faster, but make your system lag in the meanwhile.

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/blendergit pull --rebasegit submodule foreach git pull --rebase origin mastercd ~/blender-git/buildmakemake install

Notice

Both portable & system installations are supported.

Portable installation is 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.

Disable WITH_INSTALL_PORTABLE to install into CMAKE_INSTALL_PREFIX which uses a typical Unix FHS layout: bin/, share/blender/, man/ etc.

Static Linking

If you want to share your build with others (for example through graphicall), you should statically link against as much libraries as possible.


Listing needed shared libs

You can see all needed shared libraries by simply running ldd path/to/blender! Nice and easy!

Note: by default, Python is not static. To make it so, You‘ll have to edit PYTHON_LYBRARY to something like /usr/lib/x86_64-linux-gnu/libpython3.3m.a;/usr/lib/x86_64-linux-gnu/libexpat.a (exact paths depend on your OS).



Static Linking Each Library:

  • Enable general static linking
  • Set WITH_STATIC_LIBS to ON, so that CMake will try to make blender link against static libs, when available. Though not perfect, this should reduce quite nicely needed shared libs.
  • ffmpeg
  • Set the FFMPEG_LIBRARIES var to full paths of all needed libs (xvid, x264, etc.).
  • boost
  • Set (or create) Boost_USE_STATIC_LIBS to true. If you are using boost automatically built by the install_deps.sh script, you should not need to do anything else.
  • But if you are using your own distro‘s boost package, you most likely will have to set (or create) Boost_USE_ICU to true too (and install the relevant libicu development package), to get blender linking.

TODO: other libs?

See also

CMake

IDE setups with CMake

时间: 2024-10-18 06:28:33

Blender在Ubuntu上的编译的相关文章

Zynq 在Ubuntu上搭建编译环境

http://bbs.elecfans.com/jishu_487981_1_1.html 以下操作均在root用户下完成1,下载交叉编译器在ubuntu里下载arm-2010.09-62-arm-xilinxa9-linux-gnueabi.bin安装文件,,放到<myPath>/tools/中2,同步xilinx的linux kernelmkdir <myPath>/kernelcd <myPath>/kernelgit clone git://git.xilinx

.NET跨平台:在Ubuntu上用自己编译的dnx运行ASP.NET 5示例程序

在 Linux Ubuntu 上成功编译 dnx 之后,会在 artifacts/build/ 文件夹中生成 dnx-coreclr-linux-x64/ 与 dnx-mono/ 这2个文件夹,前者是基于 coreclr 的 dnx ,后者是基于 mono 的 dnx . 这篇博文中我们将使用基于 coreclr 的 dnx 运行 ASP.NET 5 示例程序,而 dnx 以及它所需的一切都在 dnx-coreclr-linux-x64/ 的 bin/ 文件夹中,所以只需通过下面的命令就可以运行

在Ubuntu上源码安装MySQL+安装问题解决+安全优化

0.说明 当然,MySQL的安装方法多种多样,在Ubuntu上,你可以采用apt-get的方式安装,这样的好处是:快速方便.基本上,它会帮你解决所有的函数库依赖问题,正常情况下,只要apt-get执行完成,那么MySQL也就可以使用了. 但我更倾向于使用源码的方式来安装MySQL,原因也很简单:除了有详细的官方文档外,你还可以非常清楚地知道你自己在做什么,这点在以后MySQL运行出现问题时将会有很大的帮助! 但即便是按照官方文档来安装,你也会遇到各种各样的问题,这里,我将呈现一个完整的过程给大家

ubuntu上安装mysql 编译安装

为什么要折腾?首先说明的是ubuntu上安装mysql等软件是非常容易简单的,其简单的程度盖过windows上的安装,一句sudo apt-get install就可以搞定.如果想用最简便的方法安装mysql,那么本文不适合你;如果你喜欢“折腾”,有兴趣了解这一条sudo apt-get install帮你做了什么,有兴趣了解internal linux的细节并想尝试自己编译软件,那么你是本文的目标读者,希望你能从这篇文章中获得收获. 编译安装的几大步骤: 编译前的准备工作 初识CMAKE——配

【转】Ubuntu 上编译Android出现cannot find -lstdc++解决办法

[转]Ubuntu 上编译Android出现cannot find -lstdc++解决办法 在Ubuntu 12.04 x86_64机器上编译Android出现下面错误,是因为找不到32bit的libstdc++.so库. /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incom

在Ubuntu上下载、编译和安装Android最新源代码

文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6559955 看完了前面说的几本书之后,对Linux Kernel和Android有一定的认识了,是不是心里蠢蠢欲动,想小试牛刀自己编译一把Android源代码了呢?一直习惯使用Windows系统,而Android源代码是不支持在Windows上编译上,于是决定使用虚拟机安装Ubuntu,然后下载.编译和安装Android源代码. 一. 环境准备

在Ubuntu上下载、编译和安装Android最新内核源代码(Linux Kernel)

文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6564592 在前一篇文章提到,从源代码树下载下来的最新Android源代码,是不包括内核代码的,也就是Android源代码工程默认不包含Linux Kernel代码,而是使用预先编译好的内核,也就是prebuilt/android-arm/kernel/kernel-qemu文件.那么,如何才能DIY自己的内核呢?这篇文章一一道来. 一. 首选

【转】在Ubuntu上下载、编译和安装Android最新源代码

原文网址:http://blog.csdn.net/luoshengyang/article/details/6559955 看完了前面说的几本书之后,对Linux Kernel和Android有一定的认识了,是不是心里蠢蠢欲动,想小试牛刀自己编译一把Android源代码了呢?一直习惯使用Windows系统,而Android源代码是不支持在Windows上编译上,于是决定使用虚拟机安装Ubuntu,然后下载.编译和安装Android源代码. 一. 环境准备. 1. 磁盘空间预留20G左右,内存3

.NET跨平台:在Linux Ubuntu上编译coreclr/corefx/dnx(20150617)

编译时间:北京2015年6月17日上午 操作系统:Ubuntu 14.04.2 LTS Mono版本:Mono JIT compiler version 4.3.0 (master/3445ac5 Tue Jun 16 20:43:48 CST 2015) 一.编译coreclr 成功! Repo successfully built. Product binaries are available at /data/git/coreclr/bin/Product/Linux.x64.Debug