[R] problems with dynamic objects on solaris

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Nov 25 18:54:21 CET 2005


On Fri, 25 Nov 2005, Ott Toomet wrote:

> Dear R people,
>
> I am working on a solaris 9 workstation with very restrictive access
> policy.  It means I have still to use R 1.7.1 and gcc 2.95.

Headers that long ago were not AFAIR written for C++, so ensure you used
extern "C" {} when including them.

> The problems is following: I have written a small function in c++ using
> boost library and I want to dyn.load the resulting .so file into R.
> Compilation works fine:
>
> /akf/705769/zpu5769/proge/R$ R CMD SHLIB pcw.cc
> g++ -I/opt2/R/lib/R/include  -I/usr/local/include   -fPIC  -g -O2 -c pcw.cc -o pcw.o
> g++ -G -L/usr/local/lib -o pcw.so pcw.o
> /akf/705769/zpu5769/proge/R$
>
> Note the resulting .so file is huge (it is only about 25kB on my
> modern linux box):

Statically linked libraries?

> /akf/705769/zpu5769/proge/R$ ll
> total 6134
> -rw-r-----+  1 zpu5769  705769      3151 nov 25 17:24 pcw.cc
> -rw-r-----+  1 zpu5769  705769      3054 nov 18 15:12 pcw.cc~
> -rw----rw-+  1 zpu5769  705769    810492 nov 25 18:00 pcw.o
> -rwxrwx---+  1 zpu5769  705769   1637112 nov 25 18:00 pcw.so
>
> However, I cannot load the object:
>
>> dyn.load("/akf/705769/zpu5769/proge/R/pcw.so")
> Error in dyn.load(x, as.logical(local), as.logical(now)) :
> 	unable to load shared library "/akf/705769/zpu5769/proge/R/pcw.so":
>  ld.so.1: /opt2/R/lib/R/bin/R.bin: fatal: relocation error: file /akf/705769/zpu5769/proge/R/pcw.so: symbol Rf_isReal__FP7SEXPREC: referenced symbol not found

Looks like name mangling of R entry points.

> Any ideas?  It works on my linux box (R 2.2.0, gcc 3.3.5).  Several
> functions I have written before, in C (and without boost), are
> working.
>
> Thanks in advance,
> Ott
>
> ______________________________________________
> 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
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list