利用者:Lusque/windows-MinGW

提供: wiki
< 利用者:Lusque
2011年3月16日 (水) 20:16時点におけるwiki>Lusqueによる版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

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

Build environment

Install the following:

  • MinGW (free, 32-bit only):
    • during install enable the C++ Compiler option
    • optionally you can enable MSYS Basic System to get a unix-like shell environment
  • Your (meta) build system of choice:
    • For cmake download the installer
    • For scons you need Python 2.6.*
      • scons itself is included in Blender sources
      • Python 3.1 dependencies for Blender itself are included in lib/windows.
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 (or both):
    • SlikSVN if you just want a command line SubVersion. This is needed in the Blender compiling process, see box below.
    • TortoiseSVN for an easy to use GUI, with Windows Explorer integration.
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 if you are using scons.

Set up your local repository

Create a folder to store your local repository. This guide will assume it is C:\BlenderSVN. Then use either commandline svn or TortoiseSvn to checkout the Blender sources and pre-compiled libs.

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 the above steps for:

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

Building Blender with 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 = '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 = '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

Compiling Blender

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


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


Building Blender with 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.


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 command prompt.