[SOLVED] Linking failed while building Blender as Python Module on CentOS 7

I was trying to build Blender Python API under the instruction from Blender-Wiki. The environment is CentOS7 with gcc-9.3.0. All dependencies were used via the official svn repo (precompiled libraries).

Here is my cmake output, and it is clear that both ZLIB and PNG are correctly located within blender-git/lib/linux_centos7_x86_64, (with version 1.2.11 and 1.6.35).

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /mnt/lustre/username/.local/bin/cc
-- Check for working C compiler: /mnt/lustre/username/.local/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /mnt/lustre/username/.local/bin/c++
-- Check for working CXX compiler: /mnt/lustre/username/.local/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- WITH_DRACO requires WITH_PYTHON_INSTALL to be ON, disabling WITH_DRACO for now
-- Performing Test SUPPORT_SSE_BUILD
-- Performing Test SUPPORT_SSE_BUILD - Success
-- SSE Support: detected.
-- Performing Test SUPPORT_SSE2_BUILD
-- Performing Test SUPPORT_SSE2_BUILD - Success
-- SSE2 Support: detected.
-- Found Git: /usr/bin/git (found version "1.8.3.1") 
-- Using pre-compiled LIBDIR: /mnt/lustre/share_data/username/software/blender-git/blender/../lib/linux_centos7_x86_64
-- Found JPEG: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/jpeg/lib/libjpeg.a (found version "80") 
-- Found ZLIB: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a (found version "1.2.11") 
-- Found PNG: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a (found version "1.6.35") 
-- Found Freetype: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/freetype/lib/libfreetype.a (found version "2.10.1") 
-- Found PythonLibsUnix: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/python/lib/libpython3.7m.a  
-- #define OPENEXR_VERSION_STRING "2.4.0"
-- Found OpenEXR: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/openexr/lib/libHalf.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/openexr/lib/libIex.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/openexr/lib/libIlmImf.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/openexr/lib/libIlmThread.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/openexr/lib/libImath.a  
-- Found OpenJPEG: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/openjpeg/lib/libopenjp2.a  
-- Found TIFF: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/tiff/lib/libtiff.a (found version "4.0.9") 
-- Found OpenAL: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/openal/lib/libopenal.a  
-- Found SDL2: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/sdl/lib/libSDL2.a  
-- Found SndFile: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/sndfile/lib/libsndfile.a  
-- Found Fftw3: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/fftw3/lib/libfftw3.a  
-- Found OpenCOLLADA: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libOpenCOLLADAStreamWriter.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libOpenCOLLADASaxFrameworkLoader.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libOpenCOLLADAFramework.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libOpenCOLLADABaseUtils.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libGeneratedSaxParser.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libMathMLSolver.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libbuffer.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libftoa.a;/mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/opencollada/lib/libUTF.a  
-- Found XML2: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/xml2/lib/libxml2.a  
-- Found JeMalloc: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/jemalloc/lib/libjemalloc.a  
-- Found Spacenav: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/spnav/lib/libspnav.a  

CMake Warning (dev) at /mnt/lustre/share_data/username/software/cmake-3.17.0/install/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
  The package name passed to `find_package_handle_standard_args` (OSL) does
  not match the name of the calling package (OpenShadingLanguage).  This can
  lead to problems in calling code that expects `find_package` result
  variables (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  build_files/cmake/Modules/FindOpenShadingLanguage.cmake:88 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  build_files/cmake/macros.cmake:105 (find_package)
  build_files/cmake/platform/platform_unix.cmake:70 (find_package_static)
  build_files/cmake/platform/platform_unix.cmake:235 (find_package_wrapper)
  CMakeLists.txt:812 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

...

But after I ran make, the error occurred:

[ 11%] Linking C executable ../../../bin/datatoc_icon
[ 11%] Building CXX object extern/bullet2/CMakeFiles/extern_bullet.dir/src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp.o
[ 11%] Building CXX object extern/bullet2/CMakeFiles/extern_bullet.dir/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp.o
[ 11%] Building CXX object extern/bullet2/CMakeFiles/extern_bullet.dir/src/BulletDynamics/ConstraintSolver/btGearConstraint.cpp.o
[ 11%] Building CXX object extern/bullet2/CMakeFiles/extern_bullet.dir/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp.o
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(png.c.o): unsupported reloc 42 against global symbol longjmp
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(png.c.o): unsupported reloc 42 against global symbol png_zalloc
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(png.c.o): unsupported reloc 42 against global symbol png_zfree
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngerror.c.o): unsupported reloc 42 against global symbol stderr
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngerror.c.o): unsupported reloc 42 against global symbol longjmp
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngerror.c.o): unsupported reloc 42 against global symbol stderr
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngread.c.o): unsupported reloc 42 against global symbol png_sRGB_table
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngread.c.o): unsupported reloc 42 against global symbol png_sRGB_delta
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngread.c.o): unsupported reloc 42 against global symbol png_sRGB_base
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngread.c.o): unsupported reloc 42 against global symbol png_sRGB_delta
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/png/lib/libpng16.a(pngread.c.o): unsupported reloc 42 against global symbol png_sRGB_base

...

/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _length_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _dist_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _dist_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _length_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _dist_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _dist_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol z_errmsg
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol z_errmsg
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _length_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol _dist_code
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol zcalloc
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol zcfree
/usr/bin/ld.gold: error: /mnt/lustre/share_data/username/software/blender-git/lib/linux_centos7_x86_64/zlib/lib/libz.a(deflate.o): unsupported reloc 42 against global symbol z_errmsg

...

I was confused why there is an against global symbol report and how can I avoid this error.
Any suggestions will be appreciated :slight_smile:

Here is the entire output after cmake: https://developer.blender.org/F9865612

Your issue might be related to this (currently not solved) one Compiling latest branch on MacOS fails (undefined symbol)

That’s a different issue, not related

1 Like

Actually, after I rebuilt both libz and libpng16 on the customed path, all compiling errors disappeared. However, linking bpy.so still failed with errors: unsupported reloc 42.
CC @nantille

The linking problem might be caused by mis-matched version of binutils (linkers including ld, ld.gold, …). Finally, everything went well after I upgraded my binutils from 2.25.1 to 2.35.2.