From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

This is how to build Blender from its SVN source using either scons or cmake.

Build environment

Install the following:

  • Your compiler of choice:
    • Visual Studio 2008 (VS 2010 is the current release, but not supported. Look for the 2008 tab from Microsoft)(Visual C++ 2008 Feature Pack may be required, included in SP1)
    • VC++ Express 2008 (free 32-bit only. Compiling 64-bit on Windows requires a 64-bit version of windows and some hacking described Here.)
    • MinGW (free, 32-bit only; must select the C++ option during install)
  • Your (meta) build system of choice:
Python bits
Only install Python x64 if you run a 64-bit version of Windows: cross-compiling x64 Blender on x86 Windows isn't supported yet.


  • A Subversion client: try SlikSVN if you just want a command line or TortoiseSVN for a full GUI.
SVN Revision in splash
Make sure you have svnversion.exe in your PATH when starting the build. It ensures you have it in your splash in in the Blenders Python API part related to application info. If you fail to do so, you'll see UNKNOWN printed in the place of a SVN revision number.
  • Optionally, the Quicktime SDK. Install it to C:\BlenderSVN\lib\windows\QTDevWin\.
  • Optionally, pywin32. This will speed the compile process.

Set up your local repository

Create a folder to store your local repository. This guide will assume it is C:\BlenderSVN

Command line

Open CMD by hitting Windows+R and typing cmd, or by searching the start menu.

At the command prompt type the following commands:

cd C:\BlenderSVN
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/blender
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows lib/windows

If you are going to be compiling 64-bit, do this too:

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

TortoiseSVN

Right-click the \BlenderSVN folder and select SVN checkout from the menu. A window will appear. For the URL of the repository enter:

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

And verify that the checkout directory is:

C:\BlenderSVN\blender

Repeat verification for:

  • https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows
    Directory: C:\BlenderSVN\lib\windows
  • https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64
    Directory: C:\BlenderSVN\lib\win64 (if you want to build 64-bit)

scons

Configure Options

Customization
Only customize these settings if you know what you are doing. The default configuration is suitable for building straight from SVN.


For building a 32-bit version of Blender save the following text as C:\BlenderSVN\blender\user-config.py:

#BF_BUILDDIR = r'c:\build' # When building with MinGW it is necessary to use as shallow path as possible - not needed to set when using MSVC
WITH_BF_FFMPEG = True
WITH_BF_OPENAL = True
WITH_BF_QUICKTIME = False # Set to True if the Quicktime SDK is installed.
WITH_BF_GAMEENGINE = True
WITH_BF_PLAYER = True
WITH_BF_JACK = True
WITH_BF_SDL = True
WITH_BF_ICONV = True
WITH_BF_COLLADA = True
WITH_BUILDINFO = True
BF_DEBUG = False
BF_NUMJOBS = 1

You can change the settings in this file.

  • If you get linking errors, examine the message. You may be able to turn off an option, such as Jack, if you get errors related to that library.
  • If you skipped installing the Quicktime SDK, set WITH_BF_QUICKTIME to False.
  • If you have a multicore machine, set BF_NUMJOBS to the number of cores + 1.

If you are building 64-bit, use this user-config.py:

#BF_BUILDDIR = r'c:\build' # When building with MinGW it is necessary to use as shallow path as possible - not needed to set when using MSVC
WITH_BF_FFMPEG = True
WITH_BF_OPENAL = True
WITH_BF_QUICKTIME = False # Not available for Win64
WITH_BF_GAMEENGINE = True
WITH_BF_PLAYER = True
WITH_BF_JACK = False # Not available for Win64
WITH_BF_SDL = True
WITH_BF_ICONV = True
WITH_BF_COLLADA = True
WITH_BF_SNDFILE = False # Not available for Win64
WITH_BUILDINFO = True
BF_DEBUG = False
BF_NUMJOBS = 1

Multiple custom configurations

You can tell the SCons build process to look for a different file than user-config.py to read settings from. You do this by specifying the path to the file with BF_CONFIG on the command-line. For a file called debugsettings in the root source directory:

python scons\scons.py BF_CONFIG=debugsettings

Compile

Visual Studio 2008 / Visual C++ 2008 Express

Open the Visual Studio Command Prompt (NOT just the normal command prompt) (if compiling for 64-bit, make sure to open the 64-bit prompt). Now add Python 2.6 to your path. Type the following:

set PATH=C:\Python26;%PATH%
Paths:
Modify the above based on where you installed Python 2.6. When installed, it may have already been added. just enter PATH and see if your Python26 is already in there. Do NOT enter the path in any quotes, as you may be tempted to if the path contains spaces.
32-bit / 64-bit Python:
Choose a Python install which corresponds to the number of bits you are building. Match an n-bit build with n-bit Python.
Non-ASCII Characters:
You might encounter problems while compiling if your computer name or some environment variables contain non-ASCII character. For best results, avoid non-ASCII characters.


Now do:

cd C:\BlenderSVN\blender
python scons\scons.py

This will compile Blender. The output and executable (blender.exe) will be found in a folder under C:\BlenderSVN\install\, such as in the win32-vc folder.

If you need to rebuild from scratch, you can clean the intermediate files with this command:

python scons\scons.py clean
cleaning a build:
The clean target will recursively remove everything under BF_BUILDDIR. Hence, never use an important directory for BF_BUILDDIR, like BF_INSTALLDIR


Compiling with MinGW

Instead of just compiling with Python SCons, you can also include MinGW in the process. To do so, create a batch file (.bat) with the following:

set PATH=%PATH%;C:\Python26;C:\MinGW\bin;C:\MinGW\lib
 
cd C:\BlenderSVN\blender\
python scons\scons.py BF_TOOLSET=mingw
32-bit / 64-bit Python:
Again, the path depends on where Python is on your machine. Choose a Python install which corresponds to the number of bits you are building. Match an n-bit build with n-bit Python.


Running the batch file will compile Blender. The output will be found at C:\BlenderSVN\install\

If you need to rebuild from scratch, you can clean the intermediate files with this command:

python scons\scons.py -c

cmake

Configure Options

Using cmake-gui

Use cmake-gui and point to the source tree (blender) and a destination directory for the temporarily object and executables files. Select the target build system (Visual Studio 9 2008 or MinGW Makefiles for example) Hit the 'configure' button twice, optionally change some settings, and hit 'generate'.

After that you can build using the generated build files.

Command-line

For Windows

mkdir msvc
cd msvc
cmake .. -G "Visual Studio 9 2008"

Compile using Visual Studio

Just open the Visual Studio solution file and compile. Make sure to build the 'INSTALL' target at least once for both Debug and Release targets. The INSTALL target will copy the scripts and python files in the appropriate directory. The install target should be built after updating SVN otherwise blender may run with old scripts.

Updating your repository

Create this batch (.bat) file in C:\BlenderSVN\:

cd lib\windows
svn update
cd ..\..\blender
svn update
pause

For 64-bit:

cd lib\win64
svn update
cd ..\..\blender
svn update
pause

Run it whenever you want to update.

Troubleshooting

Environment Variable problem

If one ore more environment variable contains a value with non-ASCII characters you'll see an error message appear since r34956 (older revision will throw a UnicodeDecodeError exception). It looks like this:

D:\blenderdev\currentsvn>python scons\scons.py BF_CONFIG=graphicall_32b
scons: Reading SConscript files ...
================
 
 
@@ ABORTING BUILD @@
 
PROBLEM DETECTED WITH ENVIRONMENT
---------------------------------
 
 
A problem with one or more environment variable was found
Their value contain non-ascii characters. Check the below
list and override them locally to be ASCII-clean by doing
'set VARNAME=cleanvalue' on the command-line prior to
starting the build process:
 
USERNAME = Näthan
TESTVAR = ElNiño

You don't have to change the main environment, it's enough to override the offending variables for the session. You could create a .bat with the overrides, so it's easy to run it whenever you open a new VS command prompt.