2016-08-14 133 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的教程來看看我能否弄清楚發生了什麼。