2016-08-14 134 views
-1

我试图安装RcppGSL作为在逃避这个库中的链接上面介绍到C后RcppGSL Windows安装麻烦

Linking GSL library to RcppGSL on Windows machine

介绍:在64升/ local323 和移动的所有文件一个目录放入链接中显示的LIB_GSL/lib中。我使用了下面的代码。

library(Rcpp) 
Sys.setenv("LIB_GSL" = "C:/local323") # this is where the library is located 
Sys.setenv("PKG_LIBS"="-L(LIB_GSL)/lib -lgsl -lgslcblas") 
install.packages("RcppGSL") 

我增加了行

Sys.setenv("PKG_LIBS"="-L(LIB_GSL)/lib -lgsl -lgslcblas") 

收到以下错误后(我仍然得到了同样的错误)做了一些研究之后,认为有可能是一个连接问题(只是猜测)。

我收到的错误是

RcppExports.o:RcppExports.cpp:(.text+0x916): undefined reference to `gsl_matrix_alloc' 
RcppExports.o:RcppExports.cpp:(.text+0x945): undefined reference to `gsl_matrix_set' 
RcppExports.o:RcppExports.cpp:(.text+0x993): undefined reference to `gsl_vector_calloc' 
fastLm.o:fastLm.cpp:(.text+0x122): undefined reference to `gsl_vector_calloc' 
fastLm.o:fastLm.cpp:(.text+0x131): undefined reference to `gsl_matrix_alloc' 
fastLm.o:fastLm.cpp:(.text+0x142): undefined reference to `gsl_multifit_linear_alloc' 
fastLm.o:fastLm.cpp:(.text+0x16d): undefined reference to `gsl_multifit_linear' 
fastLm.o:fastLm.cpp:(.text+0x175): undefined reference to `gsl_multifit_linear_free' 
fastLm.o:fastLm.cpp:(.text+0x24f): undefined reference to `gsl_matrix_diagonal' 
setErrorHandler.o:setErrorHandler.cpp:(.text+0x104): undefined reference to `gsl_set_error_handler_off' 
setErrorHandler.o:setErrorHandler.cpp:(.text+0x133): undefined reference to `gsl_set_error_handler' 

任何帮助是极大的赞赏!

行行出状元,

史蒂夫

+0

可能重复[什么是未定义的引用/未解析的外部符号错误,以及如何解决它?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved- external-symbol-error-and-how-do-i-fix) –

回答

1

我会尝试这在命令行,即在cmd.exe - 不是从R.

这样,你应该看到编译和连接步骤,这可能会有所帮助,当南下。

“它建立在CRAN ......”所以正确的文件在正确的位置,并且正确的env var也应该为你设置。

+0

这可能很明显,但我是从R到C++。我如何编译,从命令行,你有一个例子? – steve3051980

+0

在'cmd.exe'(或者另一个shell,如果你愿意的话),确保'R'在'PATH'中,然后执行'R CMD INSTALL directoryBelowYou'等。参见[编写R扩展](https:// cran。 r-project.org/doc/manuals/r-release/R-exts.html)和许多教程。 –

1

好吧,我不知道为什么下面的工作,但我能够使用RcppGSL

我跟着从我正好贴的链接的过程。然后,而不是使用

install.packages("RcppGSL") 

我下载从CRAN zip文件并通过与从ZIP安装选项将R GUI安装的程序包。这些应该是我所知道的,但使用install.packages(“RcppGSL”)。

而且

Sys.setenv("LIB_GSL" = "C:/local323")

需要随时我尝试编译使用该库的RCPP文件。

我不知道为什么,但我至少可以使用该库。

Dirk谢谢你的帮助。我将通过关于R-extensions的教程来看看我能否弄清楚发生了什么。