Question

im out of ideas

Im trying to create a library for R, but i cant get it to load.

The error im getting is

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/stenver/R/x86_64-pc-linux-gnu-    library/2.15/RcppWilcoxonTest/libs/RcppWilcoxonTest.so':
  /home/stenver/R/x86_64-pc-linux-gnu-library/2.15/RcppWilcoxonTest/libs/RcppWilcoxonTest.so:     undefined symbol: gsl_cdf_gaussian_Q
Error: loading failed

My Makevars file looks like this:

PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" `

I have tried changing all kinds of stuff in there.

My NAMESPACE file looks like this:

useDynLib(RcppWilcoxonTest)
useDynLib(gsl)
useDynLib(WilcoxonTest)

import(Rcpp)

export(RcppWilcoxonTest)

The failure happens in the dynamic shared library i am trying to use. I have copied the dynamic library files to the src folder, so R would compile them itself, but it is of no use. Ideally, i would like to keep the library and Rcpp interface implementation in a separate folders.

At some point, i also tried to use RcppGSL, but it didnt help, as R couldnt find the package after install.

The entire repository can be seen here:

https://bitbucket.org/stenver/wilxoni-astaku-test/src/8c9b5da2cd9a97fd6c1a569e468c50ca95e2e06f?at=default

in the RcppWilcoxonTest folder

Was it helpful?

Solution 2

You need something like the following in your src/Makevars file; that is (borrowing from how RcppGSL does things):

PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` `gsl-config --libs`

so R knows that it needs to link against GSL when compiling your package. See R-exts for more details.

You can probably learn a lot by checking how RcppGSL is configured to look for GSL, and use a similar approach in your package.

OTHER TIPS

Kevin's answer will probably help you, but there is in fact one CRAN package explicitly depending on RcppGSL, and in it I do

edd@max:~/git/rcppziggurat/src$ cat Makevars
PKG_CPPFLAGS = -I. -I../inst/include
## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` \
           `$(R_HOME)/bin/Rscript -e "RcppGSL:::LdFlags()"`
edd@max:~/git/rcppziggurat/src$ 

where I wrapped one line for the display here.

In essence, the RcppGSL invokes the same gsl-config that Kevin alluded to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top