[BioC] Writing R Extensions : problems

Douglas Bates bates at stat.wisc.edu
Thu Jun 10 21:09:42 CEST 2004


Richard Finney <rfinney5 at yahoo.com> writes:

> Bioconductors,
> I am trying to implement an extension to R
> which I hope to make into a bioconductor package.
> The program will process Qstar proteomics data.
> I wish to implement a function called "binandnorm".
> However, I'm getting an unresolved symbol.  The
> symbol is  "TYPEOF__FP7SEXPREC".  This problem 
> appears on 1.8.1and 1.9.0 version of R.  I have
> installed bioconductor.
> 
>     I have compiled the program using the 
>     SHLIB R command feature ... which apparently 
>     does this ..
> 
> g++ -I/usr/local/lib/R/include  -I/usr/local/include  
> -fPIC  -g -O2 -c binandnorm.cpp -o binandnorm.o
> g++ -G -L/usr/local/lib -o binandnorm.so binandnorm.o 
>  -L/usr/local/lib/R/bin -lR
> 
>     I do this to dump some symbols for later 
>     reference ...
> 
> elfdump *.so > junk
> 

>     I am running on a Sun box using R.1.8.1 ...
> 
> uname -a
> SunOS xxxxxxxxxx.xxx.nih.gov 5.8 Generic_108528-16
> sun4u sparc SUNW,Sun-Fire
> 
>     I run the R command
> 
> bash-2.03$ R
> 
> R : Copyright 2003, The R Foundation for Statistical
> Computing
> Version 1.8.1  (2003-11-21), ISBN 3-900051-00-3
> 
> R is free software and comes with ABSOLUTELY NO
> WARRANTY.
>  [blah .. blah .. blah ...] 
> Type 'q()' to quit R.
> 
> > version
>          _
> platform sparc-sun-solaris2.8
> arch     sparc
> os       solaris2.8
> system   sparc, solaris2.8
> status
> major    1
> minor    8.1
> year     2003
> month    11
> day      21
> language R
> > dyn.load("binandnorm.so")
> Error in dyn.load(x, as.logical(local),
> as.logical(now)) :
>         unable to load shared library
> "/h1/finneyr/BINANDQ/src/binandnorm.so":
>   ld.so.1: /usr/local/lib/R/bin/R.bin: fatal:
> relocation error: file
> /h1/finneyr/BINANDQ/src/binandnorm.so: symbol
> TYPEOF__FP7SEXPREC: referenced symbol not found
> > q()
> Save workspace image? [y/n/c]: n
> 
>     Rrrgghh !!!!  Well, let's see if we can find
>     TYPEOF__FP7SEXPREC ...
> 
> bash-2.03$ grep -i TYPEOF__FP7SEXPREC *
> 
>     nothing.  rrrgghhhh.
> 
>     try fgrep ...
> 
> fgrep -l TYPEOF__FP7SEXPREC *
> binandnorm.o
> binandnorm.so
> 
>      oh.  okay.  it is there.  the symbol exists
> in the object file.  why can't it get resolved
> when loaded into R ???
> 
> Anyone know what's up with this? 
> 
> I can trim down the R interface code in the C file to
> something like this ...

> 
> 
> SEXP binandnorm(SEXP SEXPalgorithm, SEXP SEXPqsize1,
>     SEXP SEXPqsize2, SEXP SEXPoutputoption,
>     SEXP SEXPoutputfilename, SEXP SEXPfilenames)
> {
>     SEXP ans;
>     ans = PROTECT(allocMatrix(REALSXP, 1, 1));
>     return NULL;
> }
> 
> and when I do the dyn.load() from R I get this ...
>   ... (blah blah ..) ... ld.so.1:
> /h1/finneyr/R-1.9.0/bin/R.bin: fatal: relocation
> error: file
> /h1/finneyr/R-1.9.0/BINANDQ/src/binandnorm.so: symbol
> Rf_allocMatrix__FUiii: referenced symbol not found
> 
>     That symbol Rf_allocMatrix__FUiii really is 
> there ...
> 

You are using a C++ compiler and will need to protect definitions of
functions to be called from R with extern "C"



More information about the Bioconductor mailing list