Disclaimer : this is not a request for help, but rather a helpful reference for the people that might encounter the same problem. I’ve asked the question/discovered the solution in blender’s chat, but this is to provide a searchable and more permanent forum post for the few that might encounter this error.
While building Blender on my system (Arch linux, GCC v11.x, glibc
v2.35) using the provided pre-compiled libraries, some linking errors appear at the end in the form of :
<Blender lib folder>/lib/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__malloc_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__malloc_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__realloc_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__realloc_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__memalign_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__memalign_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__free_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__free_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__malloc_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__realloc_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__memalign_hook'
<Blender lib folder>/linux_centos7_x86_64/usd/lib/libusd_usd_m.a(mallocHook.cpp.o):mallocHook.cpp:function usdBlender__pxrReserved__::ArchMallocHook::Initialize(void* (*)(unsigned long, void const*), void* (*)(void*, unsigned long, void const*), void* (*)(unsigned long, unsigned long, void const*), void (*)(void*, void const*), std::string*): error: undefined reference to '__free_hook'
This is due to the deprecation [1] of the internal memory hooks [2] from GCC in glibc
v2.34. Since the VFX reference platform [3] (used for building the pre-compiled libraries) requires that the version of glibc
used be at most 2.17 (which still includes those symbols).
There is an issue [4] in the USD library GitHub’s page referencing this error, which also references a pull request [5] for USD to remove those symbols from its codebase, but it has not been accepted yet.
To solve the problem, either build a ‘Lite’ version of Blender (make lite BUILD_DIR=PATH
) which does not include libUSD
if you can, or use GCC v9.3.1 like indicated in [2].
Links :
[1] The GNU C Library version 2.34 is now available
[2] Hooks for Malloc (The GNU C Library)
[3] https://vfxplatform.com/
[4] USD uses deprecated malloc hooks removed in glibc 2.34 · Issue #1592 · PixarAnimationStudios/USD · GitHub
[5] https://github.com/PixarAnimationStudios/USD/pull/1830