[R] compile error with C code and standalone R math C library

Dirk Eddelbuettel edd at debian.org
Sun Dec 14 04:25:02 CET 2003


On Sat, Dec 13, 2003 at 07:44:46PM -0500, Faheem Mitha wrote:
> I just went back to an old piece of C code. On trying to compile it with
> the R math standalone C library I got the following error. Can anyone
> enlighten me what I am doing wrong, if anything? C file (rr-sa.c) follows.
> 
> I'm on Debian sarge. I'm running R version 1.8.1. Gcc is version
> 3.3.1.
[...]
> faheem ~/co/rr/trunk>gcc -o rr rr-sa.c -lRmath -lm
> /usr/lib/gcc-lib/i486-linux/3.3.2/../../../libRmath.so: undefined
> reference to `Rlog1p'
> collect2: ld returned 1 exit status

The linker tells you that it cannot find object code for a function Rlog1p.
So let's check:

edd at chibud:~> grep Rlog1p /usr/include/Rmath.h
edd at chibud:~> grep log1p /usr/include/Rmath.h
double  log1p(double); /* = log(1+x) {care for small x} */
edd at chibud:~>

Turns out that there is none defined in Rmath.h, but log1p exists.  This may
have gotten renamed since you first wrote your code.

Hth, Dirk

-- 
Those are my principles, and if you don't like them... well, I have others.
                                                -- Groucho Marx




More information about the R-help mailing list