Search code examples
bashcompiler-errorscmakeblender

Compiling Blender BPY : recompile with -fPIC?


I tried to compile Blender BPY in Ubuntu 14.04.4 using :

mkdir ~/blender-git
cd ~/blender-git
git clone http://git.blender.org/blender.git
cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master

sudo apt-get update; sudo apt-get install git build-essential

cd ~/blender-git
./blender/build_files/build_environment/install_deps.sh

sudo apt-get install cmake cmake-curses-gui

mkdir ~/blender-git/build
cd ~/blender-git/build

cmake ../blender \
    -DWITH_PYTHON_INSTALL=OFF \
    -DWITH_PLAYER=OFF \
    -DWITH_PYTHON_MODULE=ON

cd ~/blender-git/build
make

It compiles but it ends with an error :

[100%] Building C object source/creator/CMakeFiles/blender.dir/buildinfo.c.o
Linking CXX shared module ../../bin/bpy.so
/usr/bin/ld.gold: error: /opt/lib/python-3.5/lib/libpython3.5m.a(abstract.o): requires dynamic R_X86_64_PC32 reloc against 'PyType_IsSubtype' which may overflow at runtime; recompile with -fPIC

I have the same error during pages...

Any idea ?

Is it possible to download a compiled library of blender BPY somewhere ?

Thanks !


Solution

  • Well, it tries to link a static library into a dynamic one, and that static library (/opt/lib/python-3.5/lib/libpython3.5m.a) isn't suitable for that (compiled w/o -fPIC what makes it impossible to use it in a shared library). recompile that library with the flag (or simply supply one properly compiled) and re-try with Blender BPY.

    I've just checked, Ubuntu-14.04 didn't have python-3.5 in the official repos, but there's a bunch of dedicated PPAs. But since it's the end of April of 16, it'd better to switch your apt sources.list to Xenial and update the system to the next LTS, if you feel brave, or just python if you don't :)