From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

What?

This page is just a little listing of some setup issues which make compiling Blender using SCons on Windows easier + hassle free.

MinGW

General Issues

  • 1) you ONLY NEED MinGW, not MSYS+MinGW as alluded to on the outdated New Devs Pages. MSYS is the UNIX emulation/mini-port, which MinGW can live happily without, and doesn't need unless you go down the ugly makefiles route.
  • 2a) For the sake of these notes, the paths presented are ones which work well on my computer. The drive letters may be different on your computer, and/or where you've got your blender sources too.
  • 2b) It is recommended to keep blender sources and mingw stuff on the same drive, since I had various problems trying to get resources found otherwise.
  • 2c) It is recommended (although not strictly necessary) to keep blender sources in a directory quite close to a drive name, since this minimises the chances of getting weird linking errors due to the commandlines not being long enough.
  • 3a) Make sure that you have the c:\mingw\bin folder in your PATH var
  • 3b) On Vista (and maybe beyond), you also need c:\mingw\libexec\gcc\mingw32\3.4.5\ on your path. Substitute 3.4.5 with the version number of the gcc build you've got.

Shortcuts for Opening Console

To save time navigating to the right directory to start compiling from, it is strongly recommended that you setup a shortcut that opens a command prompt ready for compiling.

Here's how to do it:

  • 1) In the folder containing the blender and lib folders, add a shortcut named blender_trunk or a suitable branch name.
  • 2) Make the shortcut point to
C:\Windows\System32\cmd.exe /k "cd c:\blenderdev\b250\blender"

where c:\blenderdev\b250 is the path to the folder where the shortcut resides.

  • 3) Leave the Start In folder as C:\Windows\System32

All going well, you should be able to doubleclick this to open a console in the blender folder with the sources.


Tips for using the console

With this console open, it's beneficial to tweak the settings of the shortcut so that everytime this console appears, it's going to behave nicely so that you can see ALL the compiler output.

  • 1) RMB on the window header, and go to Properties
  • 2) Set the settings for Screen Buffer Size to: 100 (width) and 9000 (height).
  • 3) Resize the window so that most text will not wrap when compiling.

Get familiar with using (and also from time to time) to quickly retrieve commands previously used. This saves a lot of typing (even of 3 letter commands ;), so get used to it!

Running blender once compiled is as simple as typing

..\install\blender

Batch Script for Quicker Compiling

It is also recommended that you setup some batch scripts to save yourself typing out scons compiling commands.

sgc.bat - Standard build using gcc

@REM quick script to compile blender using mingw compiler + scons (1.x)
@echo off

@REM handle special options (2nd arg should have no spaces)
if "%1" == "quicky" goto smcquicky
if "%1" == "debugy" goto smcdebugy
if "%1" == "cleany" goto smccleany
if "%1" == "profily" goto smcprofly

@REM normal case (no args)
:smcnorm
python scons/scons.py BF_TOOLSET=mingw
goto exitsmc

@REM quick compile of some libs only
:smcquicky 
python scons/scons.py BF_TOOLSET=mingw BF_QUICK=%2
goto exitsmc

@REM compile debug build
:smcdebugy
python scons/scons.py BF_TOOLSET=mingw BF_DEBUG=True BF_QUICKDEBUG=%2 BF_QUICK=%2
goto exitsmc

@REM compile profiling build
:smcprofly
python scons/scons.py BF_TOOLSET=mingw BF_PROFILE=1
goto exitsmc

@REM scons clean...
:smccleany
python scons/scons.py clean
goto exitsmc

@REM wait to get out
:exitsmc
::pause


This batch script makes compiling as simple as...

  • sgc - for normal rebuild of changed files in whole tree
  • sgc quicky lib1,lib2,... - for rebuilding select modules only
    • e.g. 1) sgc quicky anim - for rebuilding the editors/animation folder (i.e. animation editor generic code)
    • e.g. 2) sgc quicky blenkernel,anim,graph - for rebuilding blenkernel module, editors/animation (same as before), and editors/space_graph (i.e. Graph Editor)

Batch Script for Debug Build Compiling

Requires: mingw-user-config.py configuration file with options for debug builds

sgd.bat - Debug Build Compiling Script

@REM quick script to compile blender using mingw compiler + scons (1.x)
@echo off

@REM compile debug build
python scons/scons.py BF_TOOLSET=mingw BF_DEBUG=True BF_CONFIG=mingw-user-config_debug.py %*