FC14下错误 /usr/bin/ld: libvalhalla-test.o: undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

时间:2022-09-26 05:30:49

转自  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601022

Linux(FC14)下编译程序时出现下面的问题:

/usr/bin/ld: libvalhalla-test.o: undefined reference to symbol
'clock_gettime@@GLIBC_2.2'
/usr/bin/ld: note: 'clock_gettime@@GLIBC_2.2' is defined in
DSO /lib/librt.so.1 so try adding it to the linker command line
/lib/librt.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

This means that libvalhalla-test has to be linked explicitly with librt,
thus the fix proposed before (another one is to add explictly -lrt in
the corresponding Makefile).

网上的说法是在makefile中加上 -lrt , 试过,确实可以。。。