Archives for the month of: August, 2009

This guide was written for Blender 2.45.  I have an updated guide for building Blender 2.5 available HERE.

1. Acquire Blender source code and libraries

- Download and install tortoisesvn from: tortoisesvn.tigris.org
-created a folder named “blender” under c:\build, select the folder and click on SVN checkout, and use the following location:

https://svn.blender.org/svnroot/bf-blender/trunk/blender

-created a folder named “windows” under c:\build\lib, select the folder and click on SVN checkout, and use the following location:

https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows

Once the above 3 steps are done, you will have the most up-to-date blender source code and library in the world.

OPTIONAL INFO: If you want to build an official release, you can grab the more stable source code (~10MB, library files are not included) from blender.org/download/source-code. Simply delete everything under C:\build\blender and then extract the tarball to the same directory. Building from the official release ensures the Blender you compiled is stable and relatively bug-free.

2. Acquire compiling softwares

- Download and install Python 2.5.1 (9MB) from www.python.org
- Download Mingw 5.1.3 (~10MB) from www.mingw.org . Run the installer, Pick any mirror, Select Current and install packages MinGW BASETOOLS and G++ COMPILER.
- Download and install SCons 0.97 Windows (300KB) from www.scons.org
- Download the experimental GCC4.x for MinGW package from tdragon.net. Extract it to the place where you installed MinGW, and this will serve as a ‘drop in’ replacement compiler. From my own testing, GCC4 is faster than the one that comes with MinGW, but can cause trouble when compiling OpenAL.

3. Environment setup

- Go to Start Menu >> Control Panel >> System >> Advanced (Tab) >> Envoronmant Variables (button) >> System Variables scroll area double click on the PATH item
- Add the following line to the end: ;C:\Python25;C:\mingw\bin

4. Python stuff…

Copy libpython25.a from C:\Python25\libs to C:\build\lib\windows\python\lib


5. Customization (Enable/disable features, add speed optimizations)

- Create a new file named user-config.py under C:\build\blender\
- Open user-config.py with notepad and copy the following text into it.

WITH_BF_GAMEENGINE=’true’
WITH_BF_BULLET = ‘true’
WITH_BF_ODE = ‘true’
WITH_BF_OPENEXR = ‘true’
WITH_BF_FTGL = ‘true’
WITH_BF_FMOD = ‘true’
WITH_BF_FFMPEG = ‘true’
WITH_BF_QUICKTIME = ‘false’
WITH_BF_OPENAL = ‘false’
WITH_BF_SDL = ‘false’
BF_PYTHON_VERSION = ’2.5′

CCFLAGS.extend( ['-march=i686', '-ftracer', '-fomit-frame-pointer', '-finline-functions', '-ffast-math'])
CXXFLAGS.extend(['-march=i686', '-ftracer', '-fomit-frame-pointer', '-finline-functions', '-ffast-math'])

REL_CFLAGS = [ '-O3' ]
REL_CCFLAGS = [ '-O3' ]

‘-march=’ is probably the most important flag in this config file. Newer Intel CPU (Pentium D, Core 2) owners are recommended to use ‘-march=nocona’, AMD (A64, X2) owners can try ‘-march=k8′.
‘-mmmx’, ‘-msse’, ‘-msse2′, ‘-msse3′ are usually implied by using a valid march flag, therefore they are not included in the config file.
‘-ffast-math’ are in general stable enough for daily use (I’ve never seen a crash), but if you are running a real production server or can not tolorate crashes, remove this flag. It will make the binary a little slower.

This is how the directory should look like:
build2

6. Compile!

- Open a command prompt window by click on Start >> Run >> type in “cmd” and hit OK.
- Navigate to where the Blender source code is by typing this into the command prompt cd C:\build\blender
- Start the building process: scons BF_TOOLSET=mingw BF_BUILDDIR=c:\install -j4
- The above command should take about 5-10 minutes to process, and it helps if you have a dual-core processor!
- When it finishes, (Hopefully without error), you can nagivate to C:\install\win32-mingw\ and find a complete Blender installation ready to be zipped up and distributed!

Where to go from here?

You might want to rid the blender.exe of extra useless debug data by entering the following command into the command line:
strip C:\install\win32-mingw\blender.exe
This will reduce the size of the executable by 8mb or so without having any negative impact

The above ‘user-config.py’ file will result in a full-featured Blender that is optimized for speed and should run on almost all modern processors. To speed up the building process, you can chose to disable some of the features by replacing ‘true’ with ‘false’ (this will give you a blender binary without certain feaures such as gameengine, audio, etc…)
scons clean BF_TOOLSET=mingw BF_BUILDDIR=C:\install
can be used to clean the build data and getting ready for a new build


I also recommend: How to build Blender using Visual C++ Express Edition 2008 By Eugene (etr9j), MSVC produces faster binary, but takes a lot longer to setup for the first time.

This guide was written for Blender 2.45.  I have an updated guide for building Blender 2.5 available HERE.

1. Acquire Blender source code and libraries

- Download and install tortoisesvn from: tortoisesvn.tigris.org
-created a folder named “blender” under c:\build, select the folder and click on SVN checkout, and use the following location:

https://svn.blender.org/svnroot/bf-blender/trunk/blender

-created a folder named “windows” under c:\build\lib, select the folder and click on SVN checkout, and use the following location:

https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows

2. Acquire compiling softwares

- Download and install Python 2.5.1 (9MB) from www.python.org
- Download Mingw 5.1.3 (~10MB) from www.mingw.org . Run the installer, Pick any mirror, Select Current and install packages MinGW BASETOOLS and G++ COMPILER.
- Download and install SCons 0.97 Windows (300KB) from www.scons.org

3. Environment setup

- Go to Start Menu >> Control Panel >> System >> Advanced (Tab) >> Envoronmant Variables (button) >> System Variables scroll area double click on the PATH item
- Add the following line to the end: ;C:\Python25;C:\mingw\bin
- Copy libpython25.a from C:\Python25\libs to C:\build\lib\windows\python\lib

4. Compile!

Before you start, this is how the everything should look like:

build2

- Open a command prompt window by click on Start >> Run >> type in “cmd” and hit OK.

- Navigate to where the Blender source code is by typing this into the command prompt cd C:\build\blender

- Start the building process by:
scons BF_BUILDDIR=c:\install -j4

- The above command should take about 5-10 minutes to process, and it helps if you have a dual-core processor!

- When it finishes, (Hopefully without error), you can nagivate to C:\install\win32-mingw\ and find a complete Blender installation ready to be zipped up and distributed!

Where to go from here?

You might want to rid the blender.exe of extra useless debug data by entering the following command into the command line:
strip C:\install\win32-mingw\blender.exe
This will reduce the size of the executable by 8mb or so without having any negative impact

scons clean BF_BUILDDIR=C:\install
can be used to clean the build data and getting ready for a new build

Once you have successfully compiled Blender, you can try more customization by following the Advanced Guide.