[R] compilation failed for package

Roger Bivand Roger.Bivand at nhh.no
Tue Sep 21 10:20:53 CEST 2004

On Mon, 20 Sep 2004 geir.systad at nina.no wrote:

> Hello, I am new to R on Linux (and to LINUX), running a 1.9.1 on a Linux
> MDK10.0. When updating or installing different packages, I get messages
> like this (under), the package doesn't install. Can anyone help me? I
> know this is all to little information, but I don't know were to start.
> I think there is something wrong in how or were the C++ or fortran
> compilator is installed?? Thanks, Geir S.

After some offline exchanges, the problem has been resolved. This Mandrake
10.0 installation had R installed from binary, had gcc 3.4.1, but (most
likely) binutils 2.14 that did not recognise the new --as-needed flag. For
this reason, update.packages() - this was the survival case mentioned in
the post - and install.packages() failed on compilation. The fact that
such a build system is broken is demonstrated by:

$ cat << EOF > hello.c
#include <stdio.h>
int main(void)
  printf("Hello World!\n");
$ gcc -o hello hello.c
/usr/bin/ld: unrecognized option '--as-needed'
/usr/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status

Resolution by updating binutils or installing older gcc-* RPMs instead of 

> gcc -shared -L/usr/local/lib -o survival.so agexact.o agfit2.o agfit3.o agfit5.o agfit_null.o agmart2.o agmart.o agscore.o agsurv1.o agsurv2.o agsurv3.o char_date.o chinv2.o chinv3.o cholesky2.o cholesky3.o chsolve2.o chsolve3.o coxdetail.o coxfit2.o coxfit5.o coxmart.o coxph_wtest.o cox_Rcallback.o coxscho.o coxscore.o dmatrix.o doloop.o pyears1.o pyears2.o pyears3.o pystep.o surv_callback.o survdiff2.o survfit2.o survfit3.o survindex2.o survindex3.o survreg2.o survreg3.o survreg4.o survreg5.o
> /usr/bin/ld: unrecognized option '--as-needed'
> /usr/bin/ld: use the --help option for usage information
> collect2: ld returned 1 exit status
> make: *** [survival.so] Error 1
> ERROR: compilation failed for package 'survival'
> ** Removing '/usr/lib/R/library/survival'
> ** Restoring previous '/usr/lib/R/library/survival'
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no

More information about the R-help mailing list