Building Blender/Windows

From Blender Developer Wiki
Jump to: navigation, search

Building Blender on Windows

These are instructions to build Blender for Windows, with Microsoft Visual Studio. We officially support building with Visual Studio version 2015 and 2017, older versions do not work.

Quick Setup

Building Blender is not as hard as most people would think. For beginners, easiest is to follow these steps carefully. For more details and alternative ways to set up a build environment, see below.

Install Development Tools

To build Blender, Subversion, Git, CMake and Visual Studio must all be installed.

  • Install Visual Studio 2017 Community Edition (free)
  • Install Subversion for Windows (SlikSVN)
  • Install Git for Windows
    • In the installer, choose to add Git to your PATH to ensure the Git version is in the splash screen.
  • Install CMake
    • In the installer set the system path option to Add CMake to the system PATH for all users.
  • Optional for NVIDIA GPUs: install CUDA 9.1 (exact version, newer versions may not work) for CUDA support in Cycles.

Download Sources and Libraries

Create a folder to store your copy of the Blender source code. This guide will assume your chosen folder is C:\blender-git.

Then open the command prompt window by hitting Windows+R, and then typing cmd, or by searching for it in the start menu. Then type the following commands.

For 64-bit Windows, check out the precompiled libraries with Subversion like this:

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

For 32-bit Windows, use this command instead:

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

Download the Blender source code:

cd C:\blender-git
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

Compile Blender

cd C:\blender-git\blender
make full

Once the build finishes you'll get a message like this, pointing to the freshly built Blender:

Blender successfully built, run from: C:\blender-git\build_windows_Full_x64_vc14_Release\bin\Release

To update to the latest changes afterwards, run:

cd C:\blender-git\blender
make update
make full

Advanced Setup

Development Tools

Visual Studio

We support Visual Studio 2015 (Update 3) and 2017, older versions will not work. Generally newer builds will result in better Blender performance, so when installing a new version it is recommended to use 2017. The Visual Studio Community editions are free for open source development and have all the features needed for building and developing Blender. Professional editions work fine as well.

Subversion

Subversion is required for accessing precompiled libraries. The command line SlikSVN is sufficient, but alternatively TortoiseSvn can be used for an easy to use GUI, with Windows Explorer integration.

Git

Git is required for accessing the Blender source code. Git for Windows command line utilities are sufficient, but more user friendly user interfaces exist. For example TortoiseGit is the equivalent of ToroiseSvn with a GUI and Window explorer integration.

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

Download Sources and Libraries

The easiest method is to follow the quick command line steps above, to ensure everything is downloaded exactly as needed.

Alternatively GUI tools may be used to checkout and update the repositories manually. The Blender build system expects the following layout within a folder:

blender/           # Blender source code from Git, git://git.blender.org/blender.git
lib/windows_vc14   # Precompiled 32-bit libraries from Subversion, https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows_vc14
lib/win64_vc14     # Precompiled 64-bit libraries from Subversion, https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64_vc14

Under no circumstances should you set the SVN repository for the C:\blender-git 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.

Compile Blender

Automatic CMake Setup

If you're not interested in manually setting up CMake build directory, configuring, building and installing in separate steps, we provide a convenience batch file in Blender's source directory which sets up CMake for you.

To update to the latest version and build, use:

cd C:\blender-git\blender
make full

(this requires git and svn to be in your systems PATH).

There are other predefined build targets:

  • make - some are turned off by default because they can be difficult to correctly configure for newer developers and aren't essential to use & develop Blender in most cases.
  • make lite - the quickest way to get a Blender build up & running, can also help to avoid installing a lot of dependencies if you don't need video-codecs, physics-sim & cycles rendering.
  • make full - this makes a complete build with all options enabled but without the CUDA kernels.
  • make release - this makes a complete build with all options enabled including CUDA kernels, matching the releases on blender.org.

For a full list of the optional targets type...

make help

Building from within the Visual Studio IDE

If you want to work within the visual studio IDE instead of building from the command prompt.

We provide a convenience batch file in Blender's source directory which can generate a visual studio project for you

From the command line, run:

cd C:\blender-git\blender
make full nobuild

if you want to customize your build, (ie select a visual studio version, platform architecture, of blender feature set) you can get a list of customizable options by typing

make help

Once the batch file finishes it should tell you where the project files have been written, for example:

-- Build files have been written to: c:/blender-git/build_windows_Full_x64_vc14_Release

In that folder you should now find a blender.sln which you can open with the visual studio IDE.

Once opened it's very important the following steps are taken:

  • 1) In the solution explorer find the 'Blender' project (it's not the top node, should be somewhere 3/4th down the projects list) , right click it and select 'Set As StartUp Project'
  • 2) In the solution explorer find the 'INSTALL' project, right click it and select 'Build' this will copy all the required files the the blender output folder. NOTE: This needs to be done atleast *once* for every solution configuration, ie: if you switch from Debug to Release configuration you need to redo this step.

Once these settings are done, you can work with the code as usual in visual studio.

Manual CMake Setup

If you want to have more control over your build configuration or have multiple build directories for a single source directory. You can follow these steps.

Create Project Files

This step you only have to do once when first setting up the build.

Install CMake and run the CMake application, you will have to point its source path to the location you downloaded blenders GIT source to.

You will need to select a Build Path outside the source directory.

Press Configure, then Generate.

Note. any changes to the build-system will re-generate project files automatically from within MSVC when building.

Compile from MSVC (graphical user interface)

Note that if you are already familier with MSVC, Then the following steps are are much the same as building any other project file (nothing Blender specific here).

  • From MSVC you need to load the project file Blender.sln from the Build Path,
  • Select the menu item: Build -> Build Solution (this will take some minutes)
  • Build the INSTALL target listed in the Solution Explorer.
    Note: the INSTALL copies DLL's and files used by Blender to the build directory so blender.exe can start.
    If you skip this step running blender.exe will fail to start, reporting missing DLL files.
    You wont have to run this target every build, but do it after updating SVN libraries, otherwise you risk not having the correct libraries to run blender.
Compile from MSVC (command line)

You can also compile from the command line. In the following command just substitute [TARGET] with one of:
Debug, Release, RelWithDebInfo, MinSizeRel.

 devenv Blender.sln /Build [TARGET] /Project INSTALL

If you only have VC 2013 express, you have no devenv. You can then use MSBuild:

 MSBuild INSTALL.vcxproj /p:Configuration=[TARGET] /t:Build /m