Attic:Dev:Doc/Building Blender/Linux/Ubuntu Feisty Fawn
This guide will help you to compile a svn Blender version on Ubuntu Feisty Fawn. Previous versions may not need some proposed packages.
Getting the packages
Compiling Blender requires you to install quite a few packages, those are available in Synaptic :
Alternatively you can use terminal and following command:
sudo apt-get install build-essential svn-buildpackage scons libopenal-dev libalut-dev libsdl1.2-dev ftgl-dev libpng12-dev libjpeg62-dev libtiff4-dev libopenexr-dev libnspr4-dev libglut3-dev python3.1-dev libxmu-dev libart-2.0-dev libsmpeg-dev libxi-dev gettext scons yasm libsamplerate-dev libavformat-dev libswscale-dev libavdevice-dev
Note that in case you want to build blender with web plugin, you need to get mozilla-dev too. Also you need to use some other build system than scons as scons does not currently support it.
Creating directory for svn repository checkout
It is a good idea to create a directory for a checkout. mkdir command can be used for this. Example: mkdir svn-blender. This will create a new directory called svn-blender under current directory.
Downloading from svn repository
SVN has created a new folder called "blender" to store its sources, go into that directory:
Then execute this command:
Alternatively, to compile Blender without the game engine, execute:
It will take a while to complete. (~20min on a amd64) The name of the directory may vary based on name of the branch checked out.
If you get an error message with lines such as "SND_OpenALDevice.cpp:(.text+0xf05): undefined reference to `alutLoadWAVFile'" you can fix it by adding line "BF_OPENAL_LIB = 'openal alut' " (no "'s) to user-config.py which is created to the same directory in which you execute scons as above (branch/blender/).
The files are stored into ~/svn-blender/install/linux2/ Go into that directory and just type ./blender And it's done ! :)
if you dont want to always have to type in such a long path you can make a symbolic link to blender In a terminal type
ln -s ~/svn-blender/install/linux2/blender ~/svn-blender/blender
Blender optimization on ubuntu/similar distros
Now, hopefully you already compiled Blender and ran it. Maybe you thought that you want to get more power out of it? Well, its pretty simple to do.You just need to mess with linux2-config.py, which can be found in config folder(and config folder is blender root).
After you open it up you will see a lot of strange and unfamiliar settings, but don't be afraid - we wont be tweaking all of them :D You need to scroll down until you're almost at the end of the file; here you should see some similar lines:
CCFLAGS = ['-pipe','-fPIC','-march=athlon-xp','-msse2','-mmmx','-mfpmath=sse','-funsigned-char','-fno-strict-aliasing'] CPPFLAGS = ['-DXP_UNIX'] CXXFLAGS = ['-pipe','-fPIC','-march=athlon-xp','-msse2','-mmmx','-mfpmath=sse','-funsigned-char','-fno-strict-aliasing']
We will be tweaking two lines: CCFLAGS and CXXFLAFS. These two lines hold settings for available processor(cpu) instruction sets which at build time are built into executables.You see, the problem is that by default, Blender is compiled without some (maybe many) new processor instruction sets in order to make it support wider range of hardware. And as a result of such compilation, it does not harness the full power of your hardware. Personally, by optimizing my build, I got about 20% render-time speed increase. So lets start with the tweaking already,shall we ^^ ?
The whole tweaking actually is just based on adding one flag to both ccflags and cxxflags,and that is '-march=native'. We will be adding it after '-fPIC', after the semicolon we add , (another set of bracket and a semicolon) in our new empty brackets we type -march=native and thats all. If you need, use this reference.
CCFLAGS = ['-pipe','-fPIC','-march=native','-funsigned-char','-fno-strict-aliasing'] CCFLAGS = ['-pipe','-fPIC','-march=native','-funsigned-char','-fno-strict-aliasing']
Now, as our precious little config file tweak is done, we save it and compile Blender. Be aware that using march native may make your build unusable on other pcs, as this option makes gcc use all optimizations available by your hardware on compile time - in other words, other hardware can result in possible incompatibilities with optimization, which, as a result may give an nonfunctional Blender.
Warning! Do no not report bugs of optimized builds to Blender bug tracker, do so only if those bugs are encountered on official blender compilations.
To patch blender we use patch,if you dont have it then get it through apt:
sudo apt-get install patch
Don't exit terminal,cd blender source directory,and run this command in order to apply patch
patch -p0 < path to patch with patchname (for eg /home/user/muscle.diff)
Then in terminal you should see if patching was successful or not.
How to Update SVN and Compile Blender Again
Easy! Just go to the base dir of the source and svn up, then build again.
cd ~/svn-blender/blender/ svn up scons blendernogame
The up (or update) command will download the differences between your disk files and the ones in the server, so it should be faster than the co (or checkout) command. That is one adventage of building from SVN, you do not need to get the full sources again.
In rare cases, blender will not properly recompile after a SVN update. if you have trouble recompiling, its best update the sources (overwriting any changes you've made) and do a clean build. (Author's note: It is not sure if this applies for SVN. It would be good if someone could verify this.)
cd ~/svn-blender/blender/ svn up -APCd scons clean scons blendernogame