Skip to content
Prev 5019 / 10988 Next

[Rcpp-devel] undefined symbol: clock_gettime in Rcpp 0.10.2

On 12/23/2012 10:08 PM, Yan Zhou wrote:
I usually build with

~/bin$ CC=clang CFLAGS=-g -O0 CXX=clang++ ~/src/R-devel/configure 
--enable-memory-profiling --enable-R-shlib --disable-byte-compiled-packages

Looking at R's config.log carefully, I eventually spotted a difference depending 
on compilation with -O0 (when the symbol is not found) and -O2 (when everything 
is fine). The essence of the test is

~/tmp$ clang -O0 conftest.c
/tmp/conftest-hn9uU6.o: In function `main':
conftest.c:(.text+0x9): undefined reference to `clock_gettime'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
~/tmp$ clang -O2 conftest.c

for either gcc or clang, in R-2-15 or R-devel. conftest.c is, at the end of the day

#include <time.h>

int
main ()
{
#ifndef clock_gettime
   char *p = (char *) clock_gettime;
#endif

   ;
   return 0;
}

with -O2 succeeding because, well, the 'check' is optimized out (right?). This 
is from R-devel/configure.ac:1835

R_CHECK_FUNCS([clock_gettime timespec_get], [#include <time.h>])
if test "${ac_cv_have_decl_clock_gettime}" = "yes"; then
AC_CHECK_LIB(rt, clock_gettime)
fi

I'm not completely sure of this...

Martin
|    /home/mtmorgan/R/x86_64-unknown-linux-gnu-library/2.16/Rcpp/libs/Rcpp.so: