LibTorch C++: undefined reference to GLIBC

JCddUN55: <p>Hello,<br>
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:</p>
<p>cmake --build . --config Release<br>
Scanning dependencies of target example-app<br>
[ 50%] Building CXX object CMakeFiles/example-app.dir/example-app.cpp.o<br>
[100%] Linking CXX executable example-app<br>
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to <code>powf@GLIBC_2.27' /home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to </code>log2f@GLIBC_2.27’<br>
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to <code>lgammaf@GLIBC_2.23' /home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to </code>expf@GLIBC_2.27’<br>
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to <code>exp2f@GLIBC_2.27' /home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to </code>lgamma@GLIBC_2.23’<br>
/home/xyz/pytorch_cpp/libtorch/lib/libtorch_cpu.so: undefined reference to `logf@GLIBC_2.27’<br>
collect2: error: ld returned 1 exit status<br>
gmake[2]: *** [example-app] Error 1<br>
gmake[1]: *** [CMakeFiles/example-app.dir/all] Error 2<br>
gmake: *** [all] Error 2</p>
<p>The output of the cmake configure is:<br>
$ cmake -DCMAKE_PREFIX_PATH=/home/xyz/pytorch_cpp/libtorch …<br>
– The C compiler identification is GNU 9.2.0<br>
– The CXX compiler identification is GNU 9.2.0<br>
– Check for working C compiler: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/gcc<br>
– Check for working C compiler: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/gcc – works<br>
– Detecting C compiler ABI info<br>
– Detecting C compiler ABI info - done<br>
– Detecting C compile features<br>
– Detecting C compile features - done<br>
– Check for working CXX compiler: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/g++<br>
– Check for working CXX compiler: /trinity/shared/pkg/compiler/gcc/9.2.0/bin/g++ – works<br>
– Detecting CXX compiler ABI info<br>
– Detecting CXX compiler ABI info - done<br>
– Detecting CXX compile features<br>
– Detecting CXX compile features - done<br>
– Looking for pthread.h<br>
– Looking for pthread.h - found<br>
– Performing Test CMAKE_HAVE_LIBC_PTHREAD<br>
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed<br>
– Looking for pthread_create in pthreads<br>
– Looking for pthread_create in pthreads - not found<br>
– Looking for pthread_create in pthread<br>
– Looking for pthread_create in pthread - found<br>
– Found Threads: TRUE<br>
– Found Torch: /home/xyz/pytorch_cpp/libtorch/lib/libtorch.so<br>
– Configuring done<br>
– Generating done<br>
– Build files have been written to: /home/xyz/pytorch_cpp/example-app/build</p>
<p>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.</p>
<p>With kind regards, and thank you in advance.</p>

cissieAB: <p>I am having the same problem with <code>ldd 2.17</code>, <code>gcc 10.2.0</code> and <code>CentOS Linux release 7.9.2009</code> today. I degraded the libtorch to the pre-cxx11 abi version and this problem was solved.</p>
<p>I also read a post <a href="https://gist.github.com/michaelchughes/85287f1c6f6440c060c3d86b4e7d764b" rel="noopener nofollow ugc">here</a> on upgrading the libc, but I can only make it work with glibc_2.23. Building glibc_2.27 failed with my environment.</p>