Cannot use static linking with librt.a?
Hei Chan
structurechart@yahoo.com
Mon Sep 3 22:28:00 GMT 2012
Hi,
I have searched online for awhile and I still can't find a good explanation why I can't use static linking with librt.a.
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/librt.a(clock_gettime.o): In function `clock_gettime':
(.text+0x197): undefined reference to `_dl_cpuclock_offset'
collect2: ld returned 1 exit status
It seems like librt.a is a static library but it doesn't use static linking for its actual implementation _dl_cpuclock_offset?
Some people suggested (without an explanation) to explicitly specify -lpthread, but it doesn't work for me either.
$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured
with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --disable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)
Thanks in advance.
Cheers,
Hei
More information about the Gcc-help
mailing list