LibTorch C++: undefined reference to GLIBC

Hello,
I’ve been trying to install the Stable (1.11.0) Linux version of LibTorch for C++ and CPU with cxx11 ABI on a HPC system. There, using either g++ 9.2.0 or 11.2.0 and ldd 2.17, I get the following errors when following the tutorial:

cmake --build . --config Release
Scanning dependencies of target example-app
[ 50%] Building CXX object CMakeFiles/example-app.dir/example-app.cpp.o
[100%] Linking CXX executable example-app
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to powf@GLIBC_2.27' /home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to log2f@GLIBC_2.27’
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to lgammaf@GLIBC_2.23' /home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to expf@GLIBC_2.27’
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to exp2f@GLIBC_2.27' /home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to lgamma@GLIBC_2.23’
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to `logf@GLIBC_2.27’
collect2: error: ld returned 1 exit status
gmake[2]: *** [example-app] Error 1
gmake[1]: *** [CMakeFiles/example-app.dir/all] Error 2
gmake: *** [all] Error 2

The output of the cmake configure is:
$ cmake -DCMAKE_PREFIX_PATH=/home/xyz/pytorch_cpp/libtorch …
– The C compiler identification is GNU 9.2.0
– The CXX compiler identification is GNU 9.2.0
– Check for working C compiler: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/gcc
– Check for working C compiler: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/gcc – 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: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/g++
– Check for working CXX compiler: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/g++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Looking for pthread.h
– Looking for pthread.h - found
– Performing Test CMAKE_HAVE_LIBC_PTHREAD
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
– Looking for pthread_create in pthreads
– Looking for pthread_create in pthreads - not found
– Looking for pthread_create in pthread
– Looking for pthread_create in pthread - found
– Found Threads: TRUE
– Found Torch: /home/xyz/pytorch_cpp/libtorch/lib/libtorch.so
– Configuring done
– Generating done
– Build files have been written to: /home/xyz/pytorch_cpp/example-app/build

Can anyone give me a hint on how to solve that problem? Installing a different GLIBC version is, as I’ve been told, quite difficult.

With kind regards, and thank you in advance.

I am having the same problem with ldd 2.17, gcc 10.2.0 and CentOS Linux release 7.9.2009 today. I degraded the libtorch to the pre-cxx11 abi version and this problem was solved.

I also read a post here on upgrading the libc, but I can only make it work with glibc_2.23. Building glibc_2.27 failed with my environment.