[英]Rcpp cannot find gsl library
im out of ideas 我的想法
Im trying to create a library for R, but i cant get it to load. 我试图为R创建一个库,但我无法加载它。
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: 我的Makevars文件如下所示:
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: 我的NAMESPACE文件如下所示:
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.
我已将动态库文件复制到src文件夹,因此R会自行编译它们,但它没用。 Ideally, i would like to keep the library and Rcpp interface implementation in a separate folders.
理想情况下,我想将库和Rcpp接口实现保存在单独的文件夹中。
At some point, i also tried to use RcppGSL, but it didnt help, as R couldnt find the package after install. 在某些时候,我也尝试使用RcppGSL,但它没有帮助,因为R在安装后无法找到包。
The entire repository can be seen here: 整个存储库可以在这里看到:
https://bitbucket.org/stenver/wilxoni-astaku-test/src/8c9b5da2cd9a97fd6c1a569e468c50ca95e2e06f?at=default https://bitbucket.org/stenver/wilxoni-astaku-test/src/8c9b5da2cd9a97fd6c1a569e468c50ca95e2e06f?at=default
in the RcppWilcoxonTest folder 在RcppWilcoxonTest文件夹中
You need something like the following in your src/Makevars
file; 您需要在
src/Makevars
文件中使用以下内容; that is (borrowing from how RcppGSL
does things): 那是(借用
RcppGSL
如何做事):
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. 所以R知道在编译包时需要链接GSL。 See R-exts for more details.
有关详细信息,请参阅R-exts 。
You can probably learn a lot by checking how RcppGSL
is configured to look for GSL, and use a similar approach in your package. 您可以通过检查
RcppGSL
如何配置以查找GSL来学习很多东西,并在您的包中使用类似的方法。
Kevin's answer will probably help you, but there is in fact one CRAN package explicitly depending on RcppGSL, and in it I do 凯文的回答可能会对你有所帮助,但实际上有一个CRAN包明确依赖于RcppGSL,其中我做了
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. 本质上,RcppGSL调用Kevin提到的相同
gsl-config
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.