From BlenderWiki
[edit] Quickstart
NOTE: These instructions are NOT up-to-date and may not entirely work for Blender 2.40+. Thoroughly read the build instructions in blender/doc/blender-scons.txt
Since January 4th, 2004 22:11:59 CET Blender has a new build system called SCons.
SCons is now available for many platforms (see here) and for most of them these instructions are alike.
To be able to use the Blender SCons implementation you need at least Python 2.3 for the modules tarfile and shutil. The latest 2.3.x release should work fine. Then install SCons either as a library package or as a drop-in package. These instructions are for the full installation, but read the README for the SCons drop-in on how to use SCons for that.
Upon first use of SCons the system creates a config.opts in basedir/blender. This file can be used to change how a binary is build, where libraries should be searched for, what compiler to use, etc.
After a CVS update, it is good to remove the old config.opts, as SCons is still a build system in progress (see this for any changes). If you encounter problems with the build process, first remove the config.opts and retry, since it may be very well the cause of the problem.
Per default SCons will place object files in basedir/build. This can be changed in the config.opts. The first few options are the most interesting, ranging from telling whether to build a release or debug binary to choice of compiler. After those you get mainly options for library and include paths.
Go into basedir/blender where you can see the SConstruct, which is the starting point for the SCons build process. If you have run scons before with Blender, you'll find here also the config.opts.
Starting the build process is simple:
prompt> scons
If you have a SMP machine, you might want to pass -j x (with x the number of CPU's plus 1 or 2). If you're interested in seeing how long the build process takes, pass --debug=time.
When the build process has completed, you can find the new blender.exe in basedir/blender
[edit] Targets
The Blender scons implementation supports three different targets. The default is the same as issuing plain scons on the command-line:
$ scons
$ scons default
The default target doesn't do more than building Blender. The binary executable can after successfull compilation be found in the root source directory.
The second available target is 'release'
$ scons release
Using this target will give you either a bundle, a .zip or a .tar.gz, depending on your platform. During the process a dist/ directory will be created in the root source directory, but this is removed after completion. The final .zip or .tar.gz can then be found in the root source directory. For OS X this is not entirely the same [todo: write out OSX].
The third target is Windows specific. To use this target you'll need the NSIS Tool makensis.exe (http://nsis.sourceforge.net) in your path (add that manually, the installer doesn't!).
scons wininst
This will finally yield the windows installer .exe containing Blender and ready to be distributed!
Of course you can combine targets:
scons default release wininst
[edit] Note for OS X and targets
When building bf-blender 2.42a for Mac OS X on Tiger, (I strongly encourage developers to use Tiger due to the SDK changes) you'll find the following tips quite helpful:
- Building bf-blender on Mac OS X is just like building any UNIX-based app on Mac OS X. The semantics of blender are more UNIXy than Mac OS X, just FYI.
- Use the Apple-special command gcc_select to choose gcc-4.0.1 as the default compiler, like so:
sudo gcc_select 4.0.1 - AFAIK, All of the libraries you link against must be compiled against the same SDK version, e.g. 10.4u (this usually implies the same compiler and archiver, YMMV).
- Move or remove any already installed SDL libs in the /usr/local/ tree. Regardless of path settings, for some reason, the linker would always see the /usr/local/ libs and ignore the libsdl versions in the ../lib tree. If you get link-time conflicts with OpenAL, you'll know the linker is not seeing the ../lib path. (One could argue that, ideally, the build script would test for such an install--- and avoid it--- but I gave up my experiments with that (and hacking sdl-config) because the linker would never see the proper path, even when hardcoded into user-config.py. <sigh> When I moved the SDL libs aside, it all worked as expected. :D)
- Download, build, and install OpenEXR directly from OpenEXR. Presently, you are required to put this in the default location of /usr/local/. Expect this to change.
- Don't try to use MacPorts or fink to install other dependencies, use bf-blender's ../lib dependency tree. It has been carefully set up to handle the SDK changes between Panther and Tiger.
- You may also find the following command line arguments (as documented in blender/doc/blender-scons.txt and the SConstruct files) helpful:
scons BF_DEBUG=0 WITH_BF_PLAYER=yes WITH_BF_VERSE=yes BF_QUIET=0 WITH_BF_SDL=true WITH_BF_OPENEXR=true
That command will try to produce stripped player and blender binaries with verse, SDL, and OpenEXR--- and show you what's going on each step of the way. - Of course, after it builds, you may want to find the somewhat stale Xcode project in
blender/make/xc_blender/xc_blender.xcodeproj - I have found that scons will per default build an application bundle: blender.app. I have also found that the build test will succeed if you have already built blender, when using any predefined target without a
scons cleanfirst. YMMV.
[edit] Fast Cleaning
The 'normal' scons cleaning is quite slow (scons --clean or scons -c), but there are two ways to do it quicker. Either use the new 'clean' target:
scons clean
or manually delete the contents of the root_build_dir. On linux you could do that with issuing:
rm -rf ../build/linux2/*
from the root source directory of the Blender sources.
[edit] The Options
To get an in-depth overview of the available configuration options that are available for tweaking the SCons build-process, see Config.opts
Minimum version
If you're still using SCons 0.94, it is best to update to a more recent version. Some bugs, like superfluous quotes on Windows for c++ have been corrected.
Important Notes
- tcsh there have been problems with this shell (at least on OS X) where scons seems to generate lines that are too long. This will result in a 127 error from SCons.
Redirects to fix
- Hackers Guide/Build Systems → Dev:Doc/Hackers Guide/Build Systems
- Hackers Guide/Building → Dev:Doc/Hackers Guide/Building
- Hackers Guide/Config.opts → Dev:Doc/Hackers Guide/Config.opts
- Hackers Guide/Debugging → Dev:Doc/Hackers Guide/Debugging







![[]](/skins/blender/open.png)
