GLIBC linker errors when linking against libtorch on Ubuntu 18.04

Hello,

I spent a few hours on this but stuck now. I’m getting these errors below when running make in my project:

/home/t/libtorch/lib/libgomp-753e6e92.so.1: undefined reference to `clock_gettime@GLIBC_2.17’

/home/t/libtorch/lib/libgomp-753e6e92.so.1: undefined reference to `clock_getres@GLIBC_2.17’

/home/t/libtorch/lib/libtorch.so: undefined reference to `memcpy@GLIBC_2.14’

/home/t/libtorch/lib/libtorch.so: undefined reference to `lgammaf@GLIBC_2.23’

/home/t/libtorch/lib/libtorch.so: undefined reference to `lgamma@GLIBC_2.23’

Thank you!

@tiger17 Could you provide us the output of ldd --version and g++ --version? And did you download the old-ABI version or new-ABI version of libtorch?

Answering your questions:

ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27

g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

https://download.pytorch.org/libtorch/cu100/libtorch-cxx11-abi-shared-with-deps-1.2.0.zip

Wondering if there are any updates on this?

@tiger17 Do you mind trying to compile libtorch from source following the instructions at https://github.com/pytorch/pytorch#from-source? Then you can link to the compiled libtorch using cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/pytorch/folder ..

try add ‘-lrt’ to CMakeLists.txt

SET(GCC_COVERAGE_LINK_FLAGS    "-lrt")

When compiling from source following the referenced page and in the new conda env,
“python setup.py install” fails.

Part of error message:

Makefile:25: recipe for target ‘src.build’ failed

I think I tried this already.

I got the same problem (@tiger17, @yf225). What could we do with it? g++ version is 6.3.0 and ldd version is 2.24.

@tiger17, you can find a solution here: https://github.com/pytorch/pytorch/issues/27834