Cannot build blender from source on ubuntu 16.04 (Error at CMake Compile)

I’m asking the same question at https://blender.stackexchange.com/questions/108960/cannot-build-blender-from-source-on-ubuntu-16-04-error-at-cmake-compile

What I tried to do

I’m trying to build blender for the first time and ran into some errors during compiling. I use ubuntu 16.04.

Following the manual, I’ve ran:

mkdir /media/allosteric/Data/PF/BlenderBuild
cd /media/allosteric/Data//-git
git clone https://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
make update
sudo apt-get update; sudo apt-get install git build-essential
cd ..
./blender/build_files/build_environment/install_deps.sh
cd blender
make

However, this raises errors. Logs are described below. (I ran make clean;make for the second and later runs.)
Logs

Every time the log started with:

Configuring Blender in "/media/allosteric/Data/PF/BlenderBuild/build_linux" ...
-- Could NOT find Spacenav (missing:  SPACENAV_LIBRARY SPACENAV_INCLUDE_DIR) 
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   filesystem
--   regex
--   thread
--   date_time
--   locale
--   system
--   chrono
--   atomic
-- Unsupported CFLAG: -Wrestrict
-- Unsupported CXXFLAG: -Wrestrict
-- Blender Skipping: (bf_alembic;bf_collada;bf_intern_ctr;bf_intern_opencl;bf_intern_utfconv;extern_sdlew)
-- Disabling Cycles tests because tests folder does not exist

after so, the compile halts raising errors with some varieties. The followings are some examples.

[ 42%] Building C object source/blender/blenkernel/CMakeFiles/bf_blenkernel.dir/intern/navmesh_conversion.c.o
[ 42%] Linking C static library ../../../lib/libbf_blenkernel.a
[ 42%] Built target bf_blenkernel
Makefile:160: recipe for target 'all' failed
make[1]: *** [all] Error 2
GNUmakefile:128: recipe for target 'all' failed
make: *** [all] Error 2

or

[ 35%] Building C object source/blender/windowmanager/CMakeFiles/bf_windowmanager.dir/intern/wm_stereo.c.o
[ 35%] Linking C static library ../../../lib/libbf_windowmanager.a
[ 35%] Built target bf_windowmanager
Makefile:160: recipe for target 'all' failed
make[1]: *** [all] Error 2

or

[ 35%] Building C object source/blender/windowmanager/CMakeFiles/bf_windowmanager.dir/intern/wm_stereo.c.o
[ 35%] Linking C static library ../../../lib/libbf_windowmanager.a
[ 35%] Built target bf_windowmanager
Makefile:160: recipe for target 'all' failed
make[1]: *** [all] Error 2
GNUmakefile:128: recipe for target 'all' failed
make: *** [all] Error 2

and others that I haven’t kept track of.

About my PC

The OS I currently use is ubuntu 16.04 LTS. However, this is a dual-boot with a Windows 10.

The /media/allosteric/Data/PF/BlenderBuild, which is the directory I’m currently tring to build blender, is a mount of a Data Driver originally for the Windows.

My CPU is an Intel® Core™ i5-4210H CPU @ 2.90GHz × 4, which is 64-bit, and GPU is GeForce GTX 950M.

Thanks.

Hi.
Have you been able to run this command without error messages in the terminal?
https://wiki.blender.org/index.php/Dev:Doc/Building_Blender/Linux/Ubuntu/CMake

./blender/build_files/build_environment/install_deps.sh

Has it been properly install all dependencies?

Thanks for the reply. I ran the ./blender/build_files/build_environment/install_deps.sh and received the following output. I am not quite sure but I think it means there are no errors. After running the install_deps.sh I re-ran make and failed.

log

WARNING! ****WARNING****
If you are experiencing issues building Blender, _*TRY A FRESH, CLEAN BUILD FIRST*_!
The same goes for install_deps itself, if you encounter issues, please first erase everything in /home/allosteric/src/blender-deps and /opt/lib
(provided obviously you did not add anything yourself in those dirs!), and run install_deps.sh again!
Often, changes in the libs built by this script, or in your distro package, cannot be handled simply, so...

You may also try to use the '--build-foo' options to bypass your distribution's packages
for some troublesome/buggy libraries...


Ran with:
    install_deps.sh 



Installing dependencies for DEB-based distribution

Source code of dependencies needed to be compiled will be downloaded and extracted into '/home/allosteric/src/blender-deps'.
Built libs of dependencies needed to be compiled will be installed into '/opt/lib'.
Please edit $SRC and/or $INST variables at the beginning of this script,
or use --source/--install options, if you want to use other paths!

Number of threads for building: 4 (automatically detected, use --threads=<nbr> to override it).
Full install: false (use --with-all option to enable it).
Building OpenCOLLADA: false (use --with-opencollada option to enable it).

Example:
Full install without OpenCOLLADA: --with-all --skip-opencollada

Use --help to show all available options!

Do you want to continue (Y/n)?
[sudo] password for allosteric: 
Hit:1 http://jp.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://archive.ubuntulinux.jp/ubuntu xenial InRelease                                                                        
Get:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]                                                                                                        
Ign:4 http://archive.ubuntulinux.jp/ubuntu-ja-non-free xenial InRelease                                                                                                                      
Hit:5 http://archive.ubuntulinux.jp/ubuntu-ja-non-free xenial Release                                                                                                                        
Ign:6 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  InRelease                                                                                             
Hit:7 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release                                                                                                
Get:8 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]                                                                                                           
Get:11 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]                                                         
Get:12 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [319 kB]            
Hit:13 http://ppa.launchpad.net/thomas-schiex/blender/ubuntu xenial InRelease                                               
Get:14 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64x64 Icons [224 kB]                                                                             
Get:15 http://jp.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [246 kB]                                                                                   
Get:16 http://jp.archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64x64 Icons [331 kB]                                                          
Get:17 http://jp.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,964 B]                                                  
Get:18 http://jp.archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,328 B]                            
Get:19 http://jp.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [5,088 B]                               
Hit:20 http://ppa.launchpad.net/webupd8team/atom/ubuntu xenial InRelease                                                           
Get:21 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [67.8 kB]
Get:22 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64x64 Icons [68.0 kB]
Get:23 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [107 kB]
Get:24 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64x64 Icons [147 kB]
Fetched 1,846 kB in 2s (704 kB/s)                                   
Reading package lists... Done



Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libpng12-dev' instead of 'libpng-dev'
Note, selecting 'libtiff5-dev' instead of 'libtiff-dev'
bison is already the newest version (2:3.0.4.dfsg-1).
build-essential is already the newest version (12.1ubuntu2).
bzip2 is already the newest version (1.0.6-8).
flex is already the newest version (2.6.0-11).
gawk is already the newest version (1:4.1.3+dfsg-0.1).
libbz2-dev is already the newest version (1.0.6-8).
libfftw3-dev is already the newest version (3.3.4-2ubuntu1).
libglew-dev is already the newest version (1.13.0-2).
libjpeg-dev is already the newest version (8c-2ubuntu8).
liblzma-dev is already the newest version (5.1.1alpha+20120614-2ubuntu2).
libncurses5-dev is already the newest version (6.0+20160213-1ubuntu1).
libogg-dev is already the newest version (1.3.2-1).
libpng12-dev is already the newest version (1.2.54-1ubuntu1).
libreadline-dev is already the newest version (6.3-8ubuntu2).
libsdl1.2-dev is already the newest version (1.2.15+dfsg1-3).
libsqlite3-dev is already the newest version (3.11.0-1ubuntu1).
libtheora-dev is already the newest version (1.1.1+dfsg.1-8).
libtinyxml-dev is already the newest version (2.6.2-3).
libx11-dev is already the newest version (2:1.6.3-1ubuntu2).
libxi-dev is already the newest version (2:1.7.6-1).
libxinerama-dev is already the newest version (2:1.1.3-1).
libxrandr-dev is already the newest version (2:1.5.0-1).
libxxf86vm-dev is already the newest version (1:1.1.4-1).
libjemalloc-dev is already the newest version (3.6.0-9ubuntu1).
libopenal-dev is already the newest version (1:1.16.0-3).
libopenjpeg-dev is already the newest version (1:1.5.2-3.1).
libtbb-dev is already the newest version (4.4~20151115-0ubuntu3).
libyaml-cpp-dev is already the newest version (0.5.2-3).
yasm is already the newest version (1.3.0-2).
cmake is already the newest version (3.5.1-1ubuntu3).
git is already the newest version (1:2.7.4-0ubuntu1.3).
libfreetype6-dev is already the newest version (2.6.1-0.1ubuntu2.3).
libssl-dev is already the newest version (1.0.2g-1ubuntu4.12).
libtiff5-dev is already the newest version (4.0.6-1ubuntu0.4).
libvorbis-dev is already the newest version (1.3.5-3ubuntu0.2).
libxcursor-dev is already the newest version (1:1.1.14-1ubuntu0.16.04.1).
libxml2-dev is already the newest version (2.9.3+dfsg1-1ubuntu0.5).
patch is already the newest version (2.7.5-1ubuntu0.16.04.1).
wget is already the newest version (1.17.1-1ubuntu1.4).
cmake-curses-gui is already the newest version (3.5.1-1ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libsndfile1-dev is already the newest version (1.0.25-10ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libx264-dev is already the newest version (2:0.148.2643+git5c65704-1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.



Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3.6-dev is already the newest version (3.6.3-1+xenial2).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-numpy is already the newest version (1:1.11.0-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libboost-dev is already the newest version (1.58.0.1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libboost-program-options1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
libboost-filesystem1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
libboost-iostreams1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
libboost-locale1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
libboost-regex1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
libboost-system1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
libboost-thread1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
libboost-wave1.58-dev is already the newest version (1.58.0+dfsg-5ubuntu3.1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Own OpenColorIO-1.0.9 is up to date, nothing to do!
If you want to force rebuild of this lib, use the --force-ocio option.

Running ldconfig for ocio...


Reading package lists... Done
Building dependency tree       
Reading state information... Done
libopenexr-dev is already the newest version (2.2.0-10ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Own OpenImageIO-1.7.15 is up to date, nothing to do!
If you want to force rebuild of this lib, use the --force-oiio option.

Running ldconfig for oiio...


Reading package lists... Done
Building dependency tree       
Reading state information... Done
libffi-dev is already the newest version (3.2.1-4).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Own LLVM-3.4 (CLANG included) is up to date, nothing to do!
If you want to force rebuild of this lib, use the --force-llvm option.


Own OpenShadingLanguage-1.7.5 is up to date, nothing to do!
If you want to force rebuild of this lib, use the --force-osl option.

Running ldconfig for osl...



Own OpenSubdiv-3.1.1 is up to date, nothing to do!
If you want to force rebuild of this lib, use the --force-osd option.

Running ldconfig for osd...


Reading package lists... Done
Building dependency tree       
Reading state information... Done
libblosc-dev is already the newest version (1.7.0-1).
libopenvdb-dev is already the newest version (3.1.0-2).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Own Alembic-1.7.1 is up to date, nothing to do!
If you want to force rebuild of this lib, use the --force-alembic option.

Running ldconfig for alembic...


Reading package lists... Done
Building dependency tree       
Reading state information... Done
libavdevice-dev is already the newest version (7:2.8.14-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.


Ran with:
    install_deps.sh 


If you're using CMake add this to your configuration flags:
  -D WITH_CODEC_SNDFILE=ON
  -D PYTHON_VERSION=3.6
  -D WITH_OPENCOLORIO=ON
  -D OPENCOLORIO_ROOT_DIR=/opt/lib/ocio
  -D WITH_OPENIMAGEIO=ON
  -D OPENIMAGEIO_ROOT_DIR=/opt/lib/oiio
  -D WITH_CYCLES_OSL=ON
  -D WITH_LLVM=ON
  -D LLVM_VERSION=3.4
  -D OSL_ROOT_DIR=/opt/lib/osl
  -D LLVM_ROOT_DIR=/opt/lib/llvm
  -D LLVM_STATIC=ON
  -D WITH_OPENSUBDIV=ON
  -D OPENSUBDIV_ROOT_DIR=/opt/lib/osd
  -D WITH_OPENVDB=ON
  -D WITH_OPENVDB_BLOSC=ON
  -D WITH_ALEMBIC=ON
  -D ALEMBIC_ROOT_DIR=/opt/lib/alembic
  -D WITH_CODEC_FFMPEG=ON
  -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;swresample;lzma;rt;theoradec;theora;theoraenc;vorbis;vorbisenc;vorbisfile;ogg;x264;openjpeg;openjpeg_JPWL'

Or even simpler, just run (in your blender-source dir):
  make -j4 BUILD_CMAKE_ARGS="-U *SNDFILE* -U *PYTHON* -U *BOOST* -U *Boost* -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES* -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -D WITH_CODEC_SNDFILE=ON -D PYTHON_VERSION=3.6 -D WITH_OPENCOLORIO=ON -D OPENCOLORIO_ROOT_DIR=/opt/lib/ocio -D WITH_OPENIMAGEIO=ON -D OPENIMAGEIO_ROOT_DIR=/opt/lib/oiio -D WITH_CYCLES_OSL=ON -D WITH_LLVM=ON -D LLVM_VERSION=3.4 -D OSL_ROOT_DIR=/opt/lib/osl -D LLVM_ROOT_DIR=/opt/lib/llvm -D LLVM_STATIC=ON -D WITH_OPENSUBDIV=ON -D OPENSUBDIV_ROOT_DIR=/opt/lib/osd -D WITH_OPENVDB=ON -D WITH_OPENVDB_BLOSC=ON -D WITH_ALEMBIC=ON -D ALEMBIC_ROOT_DIR=/opt/lib/alembic -D WITH_CODEC_FFMPEG=ON -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;swresample;lzma;rt;theoradec;theora;theoraenc;vorbis;vorbisenc;vorbisfile;ogg;x264;openjpeg;openjpeg_JPWL'"

This information has been written to /home/allosteric/d/PF/BlenderBuild/BUILD_NOTES.txt
[ 35%] Linking C static library ../../../lib/libbf_windowmanager.a
[ 35%] Built target bf_windowmanager
Makefile:160: recipe for target 'all' failed
make[1]: *** [all] Error 2
GNUmakefile:128: recipe for target 'all' failed
make: *** [all] Error 2

When I try make I always have some may be used uninitialized blah kind of warning everywhere. However, this time, I found an error that seem to be crucial. Is this related or an independent problem?

[ 35%] Generating ../../../../release/datafiles/blender_icons16.png, ../../../../release/datafiles/blender_icons16.png.c
../../../../bin/datatoc_icon: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
source/blender/editors/datafiles/CMakeFiles/bf_editor_datafiles.dir/build.make:590: recipe for target 'release/datafiles/blender_icons16.png' failed
make[3]: *** [release/datafiles/blender_icons16.png] Error 127
CMakeFiles/Makefile2:5248: recipe for target 'source/blender/editors/datafiles/CMakeFiles/bf_editor_datafiles.dir/all' failed
make[2]: *** [source/blender/editors/datafiles/CMakeFiles/bf_editor_datafiles.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....

Check that you have the dev libpng package installed. It should be called something like libpng-dev. Once you do, try compiling again.

1 Like

Thanks for your reply. I actually did sudo apt install libpng-dev with the log of libpng12-dev is already the newst version for several times before the compile. I’m trying it again right now but I’m not optimistic about the result.

EDIT:
Tried compile but failed.
It did not end with the very same error as previous but still had the libpng16.so.16 error

I’m looking in to /home/allosteric/d/PF/BlenderBuild/build_linux/source/blender/editors/datafiles/CMakeFiles/bf_editor_datafiles.dir/build.make
for a while and looked for some files.

  1. all the files writen after release/datafiles/blender_icons16.png: were present (a whole cunk of lines writen before the 590th line)
  2. /home/allosteric/d/PF/BlenderBuild/build_linux/release/datafiles/splash_2x.png.c was not found while it was required before the 590 th line)

Maybe they are just nothing

I ran sudo apt install libpng16-dev and sudo apt install libjpeg9-dev and blend was successfully compiled.