GLIBC linker errors when linking against libtorch on Ubuntu 18.04


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/ undefined reference to `clock_gettime@GLIBC_2.17’

/home/t/libtorch/lib/ undefined reference to `clock_getres@GLIBC_2.17’

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

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

/home/t/libtorch/lib/ 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

Wondering if there are any updates on this?

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

try add ‘-lrt’ to CMakeLists.txt


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

Part of error message:

Makefile:25: recipe for target ‘’ 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:

@tiger17 @Oktai15, I am having the same issue with libtorch nightly build only ( What is the solution exactly? I checked issue 27834 and it seems like the solution is to change gcc compiler?

Yes, changing compiler actually worked for me.

export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

1 Like

@tiger17 May I ask your gcc version?