Dev:Doc/Building Blender/Windows

提供: wiki
< Dev:Doc‎ | Building Blender
2018年6月29日 (金) 03:42時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Building Blender on Windows

This is how to build Blender from its source using Microsoft compiler:

Here you find information about how to build Blender on recent ms-windows systems using MSVC 2013/2015/2017

MSVC 2015/2017
While both MSVC2015 and MSVC2017 are supported, and have no known issues, official builds are still done using 2013.


To have latest Blender successfully on your system, follow these steps.

This is not as hard as most people would think if you follow these instructions.

  1. Install necessary dependencies.
  2. Download Blender source & libraries.
  3. Compile Blender.


Install the dependencies

THIS SECTION NEEDS TO BE COMPLETED

It is recommended you install all the following dependencies in addition to MSVC: Subversion, Git, and CMake (yes, both Git and SVN). More information on each dependency is listed below.

Subversion

You must install Subversion to get access to the pre-compiled Blender Libraries (see further down). The following links are just two possible resources for getting Subversion, however, you may use any svn client you like.

  • SlikSVN A version of SVN for windows
  • TortoiseSvn for an easy to use GUI, with Windows Explorer integration.

Git

You must install Git to get access to the Blender sources.

  • Git for Windows if you just want a command line Git. This is needed in the Blender compiling process, see box below
  • TortoiseGit for an easy to use GUI, with Windows Explorer integration (equivalent of TortoiseSVN).
Revision information in splash
Make sure you have git.exe in your PATH when starting the build. It ensures you have it in your splash 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 revision hash and date.


CMake

You must install CMake to create the Build environment.

Download the installer (If you have a 64 bits Windows, you can use 32 or 64bit versions).

  • For Install Options, set the system path option to:
    Add CMake to the system PATH for all users.

Cuda (Optional)

You only need to install the CUDA development kit if you intend to use Cycles with Cuda support.

Get Cuda 9.1 from:
https://developer.nvidia.com/cuda-downloads


Visual Studio (MSVC)

This is the compiler needed to build Blender releases. Currently Blender depends on Visual Studio 2013 Update 4/5 or Visual Studio 2015 Update 3 .


Both the PRO and Community versions can be used, but only the Community version can be downloaded for free:

  • VS-2013 Community (used for official Blender builds) can be downloaded from the [old Downloads] section at Microsoft (you need to register first).
  • VS-2015 Community (compiles faster, but not much tested so far) can be downloaded from the [current versions] section at Microsoft.
  • VS-2017 Community (compiles faster, but not much tested so far) can be downloaded from the [current versions] section at Microsoft.


Community seems identical to Pro edition with license restrictions:

An unlimited number of users within an organization can use Visual Studio Community for the following scenarios: in a classroom learning environment, for academic research, or for contributing to open source projects. [Q & A on Visual Studio Community 2013 and 2015 Preview]


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

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:\blender-git in these examples.

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

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

If you plan on building 32-bit binaries with Microsoft VS-2015 or VS-2017, checkout the pre-compiled library files by typing:

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


This will checkout the libraries to lib/windows_vc12 or lib/windows_vc14 respectively.

+ Checkout 64 Bit libraries...

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

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 plan on building 64-bit binaries with Microsoft VS-2015 or VS-2017, checkout the precompiled library files by typing:

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

This will checkout the libraries to lib/win64_vc12 or lib/win64_vc14 respectively.


Using TortoiseSVN

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 with CMake

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.

From the command line, run:

cd C:\blender-git\blender
make full

Once the build finishes you'll get a message like..

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

Updating your local checkout and rebuilding is as simple as:

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

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

There are some pre-defined 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

+ Building from within the Visual Studio IDE (optional)

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_vc12_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

+ Manual CMake Setup (optional)

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.

Compiling the Project Files

You can build Blender from the graphical application or the command line.

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