From BlenderWiki

Jump to: navigation, search


Different MinGW compiler versions may NOT work. Even if blender compiles, it may not run on startup or fail otherwise. Read below on "Compiler Version" sections for supported compiler versions!

This page will describe how to build Blender from its git source, and SVN precompiled libaries using MinGW with CMake. Firstly download and install:

  1. CMake
  2. MinGW for 32-bit builds or MinGW-w64 for 64-bit builds. See below for supported versions!
  3. TortoiseSVN, used to download precompiled libraries for Blender and keep them updated.
  4. git, used to download Blender's source code and keep it updated.

TortoiseSVN Installation

Be sure to enable the command line tools during installation so you can create a .bat file later on.

git Installation

Be sure to check "Run git from the Windows Command Prompt" on the configuration page, as it add git to the PATH so you can create a .bat file allowing you to update the source code seamlessly later on.

MinGW Compiler Version

Our libraries have been compiled to be compatible with gcc version 4.6 at most. This is the version of MinGW that you will need. If the default MinGW installer comes with a newer version, you can still download older versions from their GCC packages. Be sure to enable C++ Compiler when downloading!

MinGW-w64 Compiler Version

Please be aware that MinGW-w64 support is experimental. It comes in many flavours so it is simply impossible to maintain support for each and every one, since there is no stable release.

The MinGW-w64 version that has been used for libraries and testing can be found here.

To install it, extract the mingw64 folder from the archive to your C:\ drive, or somewhere else in an easy to remember directory. Make note of this directory for use later in this page.

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://
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...

Make sure the current working directory is the top-level Blender dev directory, so C:\BlenderDEV in these examples.

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

svn checkout  lib/windows_vc12

If building 32-bit binaries with MinGW, type:

svn checkout lib/mingw32

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

+ Checkout 64 Bit libraries...

Make sure the current working directory is the top-level Blender dev directory, so C:\BlenderDEV in these examples.

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

svn checkout  lib/win64_vc12

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

svn checkout 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):
    Directory: C:\BlenderDEV\lib\windows_vc12
  • Precompiled libraries (if building 32-bit with MinGW):
    Directory: C:\BlenderDEV\lib\mingw32

+ Safe Folders for 64 Bit libraries...

  • Precompiled libraries (if building 64-bit with VS-2013):
    Directory: C:\BlenderDEV\lib\win64_vc12
  • Precompiled libraries (if building 64-bit with MinGW-w64):
    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

For MinGW (32-bit):

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

+ 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

For MinGW-w64:

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

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.

Generating projects with CMake


cmake-gui is a graphical interface for generating platform-specific project and make files with CMake.

  1. Open cmake-gui and point to the source tree (C:\BlenderSVN\blender) and a destination directory for the temporarily object and executables files. For our working example we assume you configure the generated output to go to: C:\BlenderSVN\cmake-build).
  2. Select the target build system (MinGW Makefiles for example).
  3. Hit the 'configure' button twice, optionally change some settings, then hit 'generate'. If you experience an error complaining about missing .dll's (such as libgmp-10.dll), then you will need to add C:\MinGW\bin (or C:\mingw64\bin) to your %PATH%.

After that you can build using the generated build files.

Compile using MinGW

Now cmake has generated the Makefile, open a console (run as administrator), and run make in the cmake build dir...

cd C:\BlenderSVN\cmake-build
mingw32-make install

Now you can run blender from C:\BlenderSVN\cmake-build\bin\blender.exe

Building with MinGW64

To build make sure you have extracted your compiler to C:/mingw64 and that you have set it in your $PATH. For cmake, use -DWITH_MINGW64=ON to use it. To use it with CMakeGUI, make sure the advanced mode is turned on and Add Entry variable WITH_MINGW64 set to value ON before configuring.

For redistributable builds You will have to copy the pthread library from MinGW/bin

Blender3D FreeTip.gif
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.


Fail to start release or builds from buildbot

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.

Note, MinGW64 should take care of that automatically for you if you use the supported compiler build.

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.

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\ BF_CONFIG=graphicall_32b
scons: Reading SConscript files ...
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:

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

MinGW64 & SCons on Windows might error out when compiling debug builds. Solution is to disable libmv (WITH_LIBMV=OFF on cmake, WITH_BF_LIBMV = False on scons) on those builds.

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: