Search This Blog

Wednesday 6 March 2013

Built Blender3D

    Oh yeah!!! Successfully built Blender3D for the first time. I have tried to build blender from source, so as to debug to understand it, for so many times, and I'd end up frustrated and give up the idea. But this time, I did not want to post pone. There were several, bumps along the way, but I managed to complete the task.

    This is how I invoked cmake. Blender uses two kind of build systems. One is SCons(need python) another one is Cmake(based on the concept of makefiles). I used Cmake this time.

         $ cmake ../blender \
                 -G"Unix Makefiles"  \
                 -DCMAKE_INSTALL_PREFIX:PATH=$PROGB/test-builds \
                 -DPYTHON_VERSION=3.3 \
                 -DPYTHON_INCLUDE_DIR=$PROGB/include/python3.3m \
                 -DPYTHON_LIBRARY=$PROGB/lib/libpython3.3m.so \
                 -DWITH_CYCLES=OFF \
                 -DCMAKE_BUILD_TYPE=Debug \
                 -DCMAKE_INSTALL_PREFIX=$PROGB \
                 -DWITH_BUILDINFO=ON \
                 -DWITH_BUILTIN_GLEW=ON \
                 -DWITH_BULLET=OFF \
                 -DWITH_CARVE=OFF \
                 -DWITH_CODEC_FFMPEG=OFF \
                 -DWITH_CODEC_SNDFILE=OFF \
                 -DWITH_CYCLES=OFF \
                 -DWITH_CYCLES_CUDA_BINARIES=OFF \
                 -DWITH_CYCLES_OSL=OFF \
                 -DWITH_CYCLES_TEST=OFF \
                 -DWITH_FFTW3=OFF \
                 -DWITH_GAMEENGINE=OFF \
                 -DWITH_IK_ITASC=OFF \
                 -DWITH_IMAGE_CINE=OFF \
                 -DWITH_IMAGE_DDS=OFF \
                 -DWITH_IMAGE_FRAMESERVER=OFF \
                 -DWITH_IMAGE_HDR=OFF \
                 -DWITH_IMAGE_OPENEXR=OFF \
                 -DWITH_IMAGE_OPENJPEG=ON \
                 -DWITH_IMAGE_REDCODE=OFF \
                 -DWITH_IMAGE_TIFF=OFF \
                 -DWITH_INPUT_NDOF=OFF \
                 -DWITH_INSTALL_PORTABLE=ON \
                 -DWITH_INTERNATIONAL=OFF \
                 -DWITH_JACK=OFF \
                 -DWITH_LIBMV=OFF \
                 -DWITH_LZMA=OFF \
                 -DWITH_LZO=OFF \
                 -DWITH_MOD_BOOLEAN=OFF \
                 -DWITH_MOD_DECIMATE=OFF \
                 -DWITH_MOD_FLUID=OFF \
                 -DWITH_MOD_OCEANSIM=OFF \
                 -DWITH_MOD_REMESH=OFF \
                 -DWITH_MOD_SMOKE=OFF \
                 -DWITH_OPENAL=OFF \
                 -DWITH_OPENCOLLADA=OFF \
                 -DWITH_OPENMP=OFF \
                 -DWITH_PLAYER=OFF \
                 -DWITH_PYTHON_INSTALL=OFF \
                 -DWITH_PYTHON_INSTALL_NUMPY=OFF \
                 -DWITH_PYTHON_MODULE=OFF     \
                 -DOPENCOLORIO_INCLUDE_DIR=$PROGB/include/OpenColorIO     \
                 -DOPENCOLORIO_OPENCOLORIO_LIBRARY=$PROGB/lib/libOpenColorIO.so\
                 -DOPENCOLORIO_TINYXML_LIBRARY=$PROGB/lib/libtinyxml.a   \
                 -DOPENCOLORIO_YAML-CPP_LIBRARY=$PROGB/lib/libyaml-cpp.a


   Note: $PROGB is an environment variable specific to my system. 
     Yeah. You got that right. Everything is OFF except a few, without which Blender3D cannot be built. So we can call it a minimalistic blender build.
    
    Do you notice I gave separate path for python and opencolorio. because when I tried to build for the first time, they caused errors, which pleasantly helped my ubuntu box, not even to generate the makefiles.

Putting it as timeline:

[02Mar13 09:33]
     I needed to build python as a shared object or library. I did that as follows
      $ ../configure --prefix=$PROGB --enable-shared
      $ make -j3  # i have dual core cpu
      $ make install
      $ make clean

       under build directory inside the python source folder, and then I invoked cmake with

         $ cmake ../blender  \
                 -G"Unix Makefiles"  \ 
                 -DPYTHON_VERSION=3.3  \
                 -DPYTHON_INCLUDE_DIR=$PROGB/include/python3.3m  \
                 -DPYTHON_LIBRARY=$PROG/lib/libpython3.3m.so  \
                 -DWITH_CYCLES=OFF \
                 -DCMAKE_BUILD_TYPE=Debug  \
                 -DCMAKE_INSTALL_PREFIX=$PROGB  \
                 -DWITH_BUILDINFO=ON   \
                 -DWITH_BUILTIN_GLEW=ON   \
                 -DWITH_BULLET=OFF  \
                 -DWITH_CARVE=OFF   \
                 -DWITH_CODEC_FFMPEG=OFF   \
                 -DWITH_CODEC_SNDFILE=OFF  \
                 -DWITH_CYCLES=OFF  \
                 -DWITH_CYCLES_CUDA_BINARIES=OFF  \
                 -DWITH_CYCLES_OSL=OFF  \
                 -DWITH_CYCLES_TEST=OFF  \
                 -DWITH_FFTW3=OFF   \
                 -DWITH_GAMEENGINE=OFF   \
                 -DWITH_IK_ITASC=OFF   \
                 -DWITH_IMAGE_CINE=OFF   \
                 -DWITH_IMAGE_DDS=OFF   \
                 -DWITH_IMAGE_FRAMESERVER=OFF   \
                 -DWITH_IMAGE_HDR=OFF   \
                 -DWITH_IMAGE_OPENEXR=OFF   \
                 -DWITH_IMAGE_OPENJPEG=ON   \
                 -DWITH_IMAGE_REDCODE=OFF   \
                 -DWITH_IMAGE_TIFF=OFF   \
                 -DWITH_INPUT_NDOF=OFF   \
                 -DWITH_INSTALL_PORTABLE=ON   \
                 -DWITH_INTERNATIONAL=OFF   \
                 -DWITH_JACK=OFF   \
                 -DWITH_LIBMV=OFF   \
                 -DWITH_LZMA=OFF   \
                 -DWITH_LZO=OFF   \
                 -DWITH_MOD_BOOLEAN=OFF   \
                 -DWITH_MOD_DECIMATE=OFF    \
                 -DWITH_MOD_FLUID=OFF   \
                 -DWITH_MOD_OCEANSIM=OFF   \
                 -DWITH_MOD_REMESH=OFF   \
                 -DWITH_MOD_SMOKE=OFF   \
                 -DWITH_OPENAL=OFF   \
                 -DWITH_OPENCOLLADA=OFF   \
                 -DWITH_OPENMP=OFF   \
                 -DWITH_PLAYER=OFF   \
                 -DWITH_PYTHON_INSTALL=OFF   \
                 -DWITH_PYTHON_INSTALL_NUMPY=OFF   \
                 -DWITH_PYTHON_MODULE=OFF     \

   notice the error? I almost wasted half a day on this stupid mistake. I posted to blender forums.

Forum-Post
[Sat Mar 02, 2013 1:22]
[blender.org/forum/viewtopic.php?p=103125]
=======================FORUM-POST-BEGIN==========================
Everything goes fine(just a guess!)
but when the compilation finished, it says no rule to make libpython3.3m.so, which is already built shared object(I compiled it separately from the blender). what is actually going on??

-----------------------------------------------------------------
Scanning dependencies of target blender
[100%] Building C object source/creator/CMakeFiles/blender.dir/creator.c.o
[100%] Building C object source/creator/CMakeFiles/blender.dir/buildinfo.c.o
make[2]: *** No rule to make target `/mnt/prog/lib/libpython3.3m.so', needed by `bin/blender'. Stop.
make[1]: *** [source/creator/CMakeFiles/blender.dir/all] Error 2
make: *** [all] Error 2
-----------------------------------------------------------------

here is the full screenshot of the output
http://paste.ubuntu.com/5579080/

=======================FORUM-POST-END============================

People were busy at that time, I think. There were no replies for more than 5 hours. I know, I should wait. I hanged out in IRC channel #blendercoders for a while. and someone called @plasmasolutions pointed out this mistake and I solved this with his/her help. I corrected the mistake and re-configured the build. 

[02Mar13 17:24]
    tried 
            $ make -j3                  # i have dual core cpu

here came the problem with opencolor-io. OpenColorIO required TinyXML to be built. So I installed TinyXML development packages from synaptic package manager in my ubuntu box. and re-built the project. then it told me that, it requires YAML to be built. Then I installed YAML develpoment packages and tried to re-build the project. but it did not compiled as expected. again I posted in blender forum. 


Forum-Post
[Sat Mar 02, 2013 19:19]
[blender.org/forum/viewtopic.php?p=103125]
=======================FORUM-POST-BEGIN==========================
after reconfiguring and compiling, the dependencies of OpenColorIO, TinyXML (which I didn't installed at the time) was used as a problem to throw errors on my face.
and I installed TinyXML development package. and it got solved too. now another dependency YAML is being reported "not found" and I installed yaml development package but this problem is not solved. it again shows
---------------------------------------------------------------------------------
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libOpenColorIO.a(OCIOYaml.cpp.o): In function `void YAML::operator>><float>(YAML::Node const&, std::vector<float, std::allocator<float> >&)':
(.text._ZN4YAMLrsIfEEvRKNS_4NodeERSt6vectorIT_SaIS5_EE[void YAML::operator>><float>(YAML::Node const&, std::vector<float, std::allocator<float> >&)]+0x3a7): undefined reference to `YAML::Iterator::~Iterator()'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libOpenColorIO.a(OCIOYaml.cpp.o): In function `void YAML::operator>><float>(YAML::Node const&, std::vector<float, std::allocator<float> >&)':
(.text._ZN4YAMLrsIfEEvRKNS_4NodeERSt6vectorIT_SaIS5_EE[void YAML::operator>><float>(YAML::Node const&, std::vector<float, std::allocator<float> >&)]+0x410): undefined reference to `YAML::Iterator::~Iterator()'
collect2: ld returned 1 exit status
make[2]: *** [bin/blender] Error 1
make[1]: *** [source/creator/CMakeFiles/blender.dir/all] Error 2
make: *** [all] Error 2
---------------------------------------------------------------------------------
or Can I disable OpenColorIO for now. If so, how??

=======================FORUM-POST-END============================


@ldo[http://www.blender.org/forum/profile.php?mode=viewprofile&u=73777]  from Blender forum told to build the OpenColorIO from source. so I did that. here is the conversation between us

Forum-Post from @Ido
[Tue Mar 05, 2013 13:20]
[blender.org/forum/viewtopic.php?p=103125]
=======================FORUM-POST-BEGIN==========================

I built OpenColorIO from source. It wasn’t hard, as I recall. 

=======================FORUM-POST-END============================

Forum-Post from @vanangamudi
[Tue Mar 05, 2013 15:23]
[blender.org/forum/viewtopic.php?p=103125]
=======================FORUM-POST-BEGIN==========================

I do like to build softwares from source. I will try it with OCIO. but after building how to pass the path to blender, while building it. is there any variables like OPENCOLOR_IO_PATH simlar to PYTHON_LIBRARY ???

=======================FORUM-POST-END============================

Forum-Post from @Ido
[Tue Mar 05, 2013 17:40]
[blender.org/forum/viewtopic.php?p=103125]
=======================FORUM-POST-BEGIN==========================


Yes, you can pass all that kind of thing in CMake variables. I have a wrapper script I use to build Blender, here is the line in it that does the CMake setup (notice all the explicit OPENCOLORIO_xxx and OPENIMAGEIO_xxx definitions):


Code:
$ cmake \
    -D WITH_PLAYER=ON \
    -D WITH_PYTHON_INSTALL=OFF -D PYTHON_VERSION=3.3 \
    -D PYTHON_INCLUDE_DIR=/usr/include/python3.3m \
    -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.3m.so \
    -D WITH_FFTW3=ON -D WITH_MOD_OCEANSIM=ON \
    -D OPENCOLORIO_INCLUDE_DIR=/usr/local/OpenColorIO/include \
    -D OPENCOLORIO_OPENCOLORIO_LIBRARY=/usr/local/OpenColorIO/lib/libOpenColorIO.so \
    -D OPENCOLORIO_TINYXML_LIBRARY=/usr/local/OpenColorIO/lib/libtinyxml.a \
    -D OPENCOLORIO_YAML-CPP_LIBRARY=/usr/local/OpenColorIO/lib/libyaml-cpp.a \

    -D OPENIMAGEIO_INCLUDE_DIR=/usr/include \
    -D OPENIMAGEIO_LIBRARY=/usr/lib/libOpenImageIO.so \
    -D WITH_OPENCOLLADA=ON \
    -D WITH_CODEC_FFMPEG=ON -D FFMPEG=/usr/local -D WITH_JACK=ON \
    -D FFMPEG_LIBRARIES="avdevice;avfilter;avformat;avcodec;avutil;swscale;swresample;postproc;nut;bz2;faac;faad;gsm;jack;modplug;mp3lame;opencore-amrnb;opencore-amrwb;rtmp;schroedinger-1.0;speex;theoraenc;theoradec;vpx;x264;xvidcore" \
    -D WITH_CODEC_SNDFILE=ON \
    ../"$SRCDIR"
(../"$SRCDIR" is the Blender source directory,)

=======================FORUM-POST-END============================

[05Mar13 18:34]
I downloaded the OpenColorIO source and built it. 
with cmake invocation...
     $ cmake ../ -DCMAKE_INSTALL_PREFIX:PATH=$PROGB

    at first I just followed the same procedure as I did for python shared library. but the libraries TinyXML and YAML did not properly installed to $PROGB location. then I re-built the OpenColorIO and checked for the mentioned libraries. I found them under $OCIO_SRC/build/ext/dist. there were four directories namely 

  1.    bin/
  2.    include/
  3.    lib/
  4.    share/


    I copied them into the $PROGB directory. and then tried to rebuilt the Blender project and it just did. Blender3D compiled successfully. but when I launched blender, the buttons and menus were missing. because i did not installed the python scripts into proper location. note: blender executables and object files were under $BLENDER_SRC/build/bin

Briefly...
    Build python shared library
    Build OpenColorIO shared library along with
          TinyXML and
          YAML
    Build Blender3D

Things learned...
    this is not my first attempt to use cmake. I used it to build OpenCV. but there are things to ponder
        make                   cmake
       --prefix           CMAKE_INSTALL_PREFIX:PATH
    CFALGS=-g    CMAKE_BUILD_TYPE

    I should thank the people who helped me to do this.

  •         Ido [blender.org/forum/profile.php?mode=viewprofile&u=73777]
  •         plasmasolutions
  •         stiv [blender.org/forum/profile.php?mode=viewprofile&u=5874]

    Moral of the story: try, try and try, if it doesn't work, then try harder.

No comments:

Post a Comment