From BlenderWiki

Jump to: navigation, search

Introduction

This is how to build Blender from its SVN source using MinGW with CMake. After setup all properly, in the future, for automatic downloading current SVN and compile it - just run .bat file ! Firstly download and install:

  1. CMake http://www.cmake.org/cmake/resources/software.html
  2. MinGW http://www.mingw.org/wiki/Getting_Started
  3. TortoiseSVN http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-intro-install.html (You don't need to install TortoiseSVN, instead use just Windows Command line).

Set up your Repository

Create a folder to store your copy of the Blender source code. This guide will assume your chosen folder is C:\BlenderDEV. Then use the command-line to download the Blender source code via git and precompiled libraries via SVN.

Note, to get the precompiled libraries you can use the command-line OR TortoiseSVN, no need to do both, however the command-line is relatively easy to do.

Using the Command line

Open the command prompt window by hitting Windows+R, and then typing cmd, or by searching for it in the start menu.

At the command prompt type the following commands:

cd C:\BlenderDEV
git clone git://git.blender.org/blender.git
cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master

This will checkout the source files to blender/

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

+ Checkout 32 Bit libraries...

If you plan on building 32-bit binaries with Microsoft VS-2013, checkout the precompiled library files by typing:

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

If building 32-bit binaries with Microsoft VS-2008, checkout the precompiled library files by typing:

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

If building 32-bit binaries with MinGW, type:

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

This will checkout the libraries to lib/windows/ or lib/mingw32/ respectively.

+ Checkout 64 Bit libraries...

If you plan on building 64-bit binaries with Microsoft VS-2013, checkout the precompiled library files by typing:

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

If you are going to be compiling 64-bit binaries using Microsoft VS-2008, do this instead for the libraries:

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

Otherwise if building 64-bit binaries with MinGW-w64, type:

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

Again, this will check the libraries out in lib/win64/ or lib/mingw64/ respectively.


Using TortoiseSVN

Under no circumstances should you set the SVN repository for the C:\BlenderDEV folder, because it could cause major conflicts with the git repository. If you want to update each precompiled library folder with the explorer context menu, you can do so by clicking on the requisite folders under lib/ and going to SVN checkout. After the checkout finishes you will see a revision and are able to close the dialog out.

The only safe folders that you should use this feature on are the following:

+ Safe Folders for 32 Bit libraries...

  • Precompiled libraries (if building 32-bit with VS-2013):
    Repository: https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows_vc12
    Directory: C:\BlenderDEV\lib\windows_vc12
  • Precompiled libraries (if building 32-bit with VS-2008):
    Repository: https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows
    Directory: C:\BlenderDEV\lib\windows
  • Precompiled libraries (if building 32-bit with MinGW):
    Repository: https://svn.blender.org/svnroot/bf-blender/trunk/lib/mingw32
    Directory: C:\BlenderDEV\lib\mingw32

+ Safe Folders for 64 Bit libraries...

  • Precompiled libraries (if building 64-bit with VS-2013):
    Repository: https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64_vc12
    Directory: C:\BlenderDEV\lib\win64_vc12
  • Precompiled libraries (if building 64-bit with VS-2008):
    Repository: https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64
    Directory: C:\BlenderDEV\lib\win64
  • Precompiled libraries (if building 64-bit with MinGW-w64):
    Repository: https://svn.blender.org/svnroot/bf-blender/trunk/lib/mingw64
    Directory: C:\BlenderDEV\lib\mingw64


Update your repository

To keep your local Blender source code and precompiled libraries up to date, you will need to do a git and SVN update once in a while. The most convenient way of doing this is to make a batch file containing the necessary commands.

Command line

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

+ Update 32 Bit libraries...

For Microsoft VS-2013 32-bit:

cd lib\windows_vc12
svn update
cd ..\..\blender
git pull --rebase
git submodule foreach git pull --rebase origin master
pause

For Microsoft VS-2008 32-bit:

cd lib\windows
svn update
cd ..\..\blender
git pull --rebase
git submodule foreach git pull --rebase origin master
pause

For MinGW (32-bit):

cd lib\mingw32
svn update
cd ..\..\blender
git pull --rebase
git submodule foreach git pull --rebase origin master
pause

+ Update 64 Bit libraries...

For Microsoft VS-2013 64-bit:

cd lib\win64_vc12
svn update
cd ..\..\blender
git pull --rebase
git submodule foreach git pull --rebase origin master
pause

For Microsoft VS-2008 64-bit:

cd lib\win64
svn update
cd ..\..\blender
git pull --rebase
git submodule foreach git pull --rebase origin master
pause

For MinGW-w64:

cd lib\mingw64
svn update
cd ..\..\blender
git pull --rebase
git submodule foreach git pull --rebase origin master
pause


Run this newly created .bat file whenever you want to update.

TortoiseSVN Explorer Menu

If you plan to compile different versions of Blender with different compilers or targets, and need to have more than one of the precompiled libraries, you can update them individually by right clicking on the requsite library under C:/BlenderDEV/lib/PRECOMPILED-LIB where "PRECOMPILED-LIB" are the following:

C:/BlenderDEV/lib/windows, C:/BlenderDEV/lib/win64, C:/BlenderDEV/lib/mingw32, and/or C:/BlenderDEV/lib/mingw64

Once you right click on the C:/BlenderDEV/lib/PRECOMPILED-LIB folder you should choose the SVN Update option. A TortoiseSVN window will appear listing the files that are updating.

Once the process is finished it will print Completed At Revision: xxxxx at the end of the list.

Just click the OK button to dismiss the dialog.

  1. REDIRECT Dev:2.5/Doc/Building Blender/Windows/cmake

Troubleshooting

Compile errors with Visual Studio 2008 PRO

When you get compile errors with functions from the c++ std:: library then please make sure that you have the "Visual studio 2008 Service pack 1" installed besides your Visual Studio 2008 Pro installation.

Fail to start release or builds from buildbot

Usually this means the Install the Visual C++ 2008 Redistributable Package aren't installed in your system. They can be easily found at the Microsoft download center here: 32bit / 64bit (see also the Download Blender page).

If you've got PYTHONPATH environment variable pointing to an older version of Python, it'll lead to Microsoft Visual C++ runtime library failure. If you've got such kind of error message, check on your environment variables.

Missing DLL's With MinGW

If you get a popup when configuring CMake or running SCons that says

libgmp-10.dll not found

This is because the DLL MinGW installs is not in the path, resolve this by adding "C:\MinGW\bin" to you're PATH environment variable.


MinGW & Redistribution

MinGW uses a few DLLs deal with runtime libraries so if you bundle builds for others, copy libgcc*.dll and libstdc++*.dll from MinGW/bin next to your new Blender executable. If you build with OpenMP, libgomp.dll will also be needed. This will make the builds usable even for people who don't have MinGW or PATH setup correctly.

Fail to Initialize with MinGW

If you get this error, installing python may resolve this, even though Blender comes with python.

The application failed to initialize properly (.....)
Click on OK to terminate the application.

Debug Builds

Without MSVC 2008 installed you may get an error like this on launch.

The application failed to initialize properly (0xc9159992).
Click on OK to terminate the application.

This is because python32_d.dll needs MSVC 2008 installed to run. Both the Full version or Express will work.

So even if you build with MinGW or MSVC 2010, to run debug builds you need MSVC 2008.

MSVC 2008 Express Has No OpenMP support

If you build with MSVC Express you must disable OpenMP (which will make some parts of Blender not use multiple processors).

  • on SCons disable WITH_BF_OPENMP
  • on CMake disable WITH_OPENMP

SCons 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.

File too big

So far only encountered with MinGW64 & SCons on Windows.

No real solution found yet, but disabling debug builds is a workaround. Here is an example for SCons:

BF_DEBUG = False

If there is more information about this, please update this entry!


MinGW and Eclipse

Using Scons plugin to import blender as project does not work properly with MinGW (32Bit). Just add another Scons option in the project's plugin settings:

BF_BITNESS=32