From BlenderWiki

Jump to: navigation, search
Blender2.5
Instructions for building Blender2.5 should be placed here


Building Blender with C++ Express and Scons on Windows XP/Vista

Install the following Applications / Libraries

1. MS C++ Express

2. Python 2.5

3. Scons

4. Windows SDK for your version of Windows

5. DirectX SDK

6. TortoiseSVN

7. Download /trunk/lib/windows from SVN (contains all the libs for windows)

8. Download and copy the Quicktime Dev Kit to lib/windows/QTDEVWIN

In blender/config/win32-vc-config.py

set openexr path to lib_vs2005

In windows Environment Variables

Add the following paths (replace with your installation paths if different)

PATH add c:\python25

INCLUDE add C:\Program Files\Microsoft Visual Studio 8\VC\include

INCLUDE add C:\Program Files\Microsoft SDKs\Windows\v6.0\Include

LIB add c:\DX90SDK\lib;

LIB add C:\Program Files\Microsoft SDKs\Windows\v6.0\lib

Download SVN Trunk

run scons from the Blender Folder.


For ease, make this batch file This will update your SVN, and rebuild your checkout.

  c:
  cd\blendersvn
  "c:\Program  Files\TortoiseSVN\bin\TortoiseProc" 
  /command:update /path:c:\blendersvn\blender\ /closeonend:1 /notempfile
  cd blender
  call scons

If you download multiple branches, change the build folder in config/win32-vc-config.py, but leave the install folder normal. Then in the /Sconstruct file at around line 317 there is a reference to env.BlenderProg(B.root_build_dir, "blender" change the "blender" to another name and that is what that branches exe will be called.

CMake

CMake -G "Unix Makefiles"
CMake -G "Visual Studio"

Various other build and compiler specific guides

These guides are listed here in the hope that you find them useful. The usual disclaimers apply, the guides are not maintained by the blender documentation team.

blender.org Development Forum sticky thread for compiling blender on a wide variety of platforms

For Windows using MSVC and SCons !!!Error 6/20/2009: Nothing here by that name!!!

For Windows using MSVC and CMake

For Windows using MinGW and SCons

Project Files

Now with the introduction of CMake, Visual Studio, and XCode project files are probably not going to be directly maintained. Project files support tends to lag behind the other build systems, unless you must use these hand-maintained project files, use one of the other build systems. Otherwise, you should be using CMake to generate project files.

VS Build Files
 bf-blender/blender/projectfiles (for MSVC6)
 bf-blender/blender/projectfiles_v7
 bf-blender/blender/extern/make
 bf-blender/blender/intern/make
Where VS Puts things
 bf-blender/build
 bf-blender/blender/bin
XCode Project Files
 bf-blender/make/xc_blender/


Structure of the bf-blender code tree

This is a folder by folder explanation of the bf-blender source code tree. This should help you answer questions such as "is this the right place to put includes for internal use?"



File Types in the Source Tree

There are all kinds of various files inside of the source code. Here is a list of the major types of files you will be dealing with and how to identify what they are.

Executables
-- Filename -- -- File Type --
blender Unix has no extension for binary file types
.exe Windows Executable
.app OSX Executable

Compiler Basics

There are a few basic areas people tend to have issues with. A quick rundown of them and how to fix them follow. The following is based on GCC, other compilers will work similarly but the details will differ. The links have carefully crafted examples of the issues and their solutions for both Makefiles and SCons.

  • Unable to find a header (.h)
Use -I(dir) Example: -I/usr/local/include
  • Unable to find shared library when linking (.so, .dll)
Use -L(dir) -l(lib) Example: -L/usr/local/lib -lm
  • Unable to find static library when linking (.a)
Use full path to library Example: /usr/local/lib/libjpeg.a
  • Unable to find shared library when running app
Use -L(dir) -Wl,-rpath -Wl,(dir) -l(lib) 
Example: -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -ljpeg
On solaris need to use -L(dir) -R(dir) -l(lib)
Example: -L/usr/local/lib -R/usr/local/lib -ljpeg
  • Undefined symbol: blahhhh
Need to include extra library (static or dynamic)

Troubleshooting

Error: png.h: No such file or directory

Possible Problems:

Library not installed
Determine library (websearch, educated guess)
Install the library.
 Note: on linux its common that the library may be installed but the "dev" 
 package for the library is not installed.  In that case you need to install
 it also.
Blender thinks library is in a different place
Makefiles: add to user-def.mk  export NAN_PNG=/usr  
SCons: add to user-config.py  BF_PNG=/usr
Some headers are in different locations depending on distribution.
 Example: /usr/local/include/Freetype vs /usr/local/freetype/include
 To fix this you need to dive down deeper into the build system.
   Makefiles: You probably need to find specific Makefiles with NAN_FREETYPE
     and modify them.
     grep NAN_FREETYPE `find . -name Makefile -print`
   Scons: You will need to edit user-config.py and add/modify
     BF_FREETYPE, BF_FREETYPE_INC, BF_FREETYPE_LIB (possibly more)

Error: No Rule to make target '/blender/lib/libpng.a' needed by /blender/obj/.........

Possible Problems:

Library not installed

(See above section in missing .h)

Blender looking for library in wrong location

(see above section in missing .h)

You may have a dynamic lib installed and its expecting a static lib

Install the static lib as well, or modify compile options to use dynamic lib instead of static lib.

Error: cannot find -lpng

Possible Problems:

Library not installed

(See above section in missing .h)

Blender looking for library in wrong location

(see above section in missing .h)

You may have a static lib installed and its expecting a dynamic lib

Install the dynamic lib as well, or modify compile options to use static lib instead of dynamic lib.

Error: Undefined symbol _vorbis

You have an out of date library

First thing to try is do a cvs update, both blender and your lib directory if you are using a lib directory. Then do a clean build.

  For Makefiles rm -rf obj/(platform)   You will need to look at your obj dir
     to figure out what (platform should be)
  For Scons do scons clean.
You are using a library that has extra dependancies blender does not know about

In this case you will need to figure them out and then add the extra dependancies.

External links that walk you through various build methods

List of External Dependencies (for if you need to obtain them manually)

Building Blender with Scons Mingw/Windows Tutorial (Includes Getting CVS, Installing build tools and debugging using all free tools).

Scons instructions from CVS.

Building Blender With Make using Cygwin

Compiler Tools

Compiling with VC7 - Note that the project files are now vc7.1.

Compiling Blender on Ubuntu Feisty Fawn

If there are problems compiling, feel free to join #blendercoders on irc.freenode.net for assistance. If someone can help, it's generally standard procedure to switch over to #blendercompilers, so people arn't conducting complex debugging in #blendercoders itself. Please note: use an online paste bin (such as pastebin.com or Rafb paste) for large error messages, don't paste them into irc!


Make

Make + MinGW
Make + Cygwin
import Blender
 from Blender import Armature
 from Blender.Mathutils import *
 #
 arms = Armature.Get()
 for arm in arms.values():
   arm.drawType = Armature.STICK #set the draw type
   arm.makeEditable() #enter editmode
 
   #generating new editbone
   eb = Armature.Editbone()
   eb.roll = 10
   eb.parent = arm.bones['Bone.003']
   eb.head = Vector(1,1,1)
   eb.tail = Vector(0,0,1)
   eb.options = [Armature.HINGE, Armature.CONNECTED]
 
   #add the bone
   arm.bones['myNewBone'] = eb
 
   #delete an old bone
   del arm.bones['Bone.002']
 
   arm.update()  #save changes
 
   for bone in arm.bones.values():
     #print bone.matrix['ARMATURESPACE']
     print bone.parent, bone.name
     print bone.children, bone.name
     print bone.options, bone.name

Example:

       # Adds empties for every bone in the selected armature, an example of getting worldspace locations for bones.
       from Blender import *
       def test_arm():
               scn= Scene.GetCurrent()
               arm_ob= scn.objects.active
 
               if not arm_ob or arm_ob.type != 'Armature':
                       Draw.PupMenu('not an armature object')
                       return
 
               # Deselect all
               for ob in scn.objects:
                       if ob != arm_ob:
                               ob.sel= 0
 
               arm_mat= arm_ob.matrixWorld
 
               arm_data= arm_ob.getData()
 
               bones= arm_data.bones.values()
               for bone in bones:
                       bone_mat= bone.matrix['ARMATURESPACE']
                       bone_mat_world= bone_mat*arm_mat
 
                       ob_empty= scn.objects.new('Empty')
                       ob_empty.setMatrix(bone_mat_world)
 
       test_arm()

Scons

Scons + MinGW
Scons + Cygwin
Scons + MSVC