-1

I'm trying to install RcppGSL as presented in

Linking GSL library to RcppGSL on Windows machine

after copping the library as presented in the link above to C:/local323 and moving all the files in x64 up one directory into into LIB_GSL/lib as presented in the link. I used the following code.

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")

I added the line

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

after getting the following error(and I still got the same error) after doing some research and thought there might be a linking problem(just guessing).

The error I received was

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'

any help is greatly appreciated!

Very best,

Steve

Community
  • 1
  • 1
steve3051980
  • 129
  • 3
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Aug 14 '16 at 02:22

2 Answers2

1

I would try this on the command-line, ie in cmd.exe -- not from R.

That way you should see the compilation and linking steps which may help when something go south.

"It builds at CRAN ..." so with the right files in the right location, and the proper env var set it should for you too.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • This might be obvious but I'm coming from R to C++. How would I compile, from the command line, do you have an example? – steve3051980 Aug 14 '16 at 13:15
  • In `cmd.exe` (or another shell if you prefer), ensure `R` is in the `PATH` and then do `R CMD INSTALL directoryBelowYou` etc. See [Writing R Extensions](https://cran.r-project.org/doc/manuals/r-release/R-exts.html) and many tutorials. – Dirk Eddelbuettel Aug 14 '16 at 13:16
1

Well I do not know why the following worked but I'm able to use RcppGSL

I followed the procedure from the link I posted exactly. Then instead of using

install.packages("RcppGSL") 

I downloaded the zip file from CRAN and installed the package via the R GUI with the option to install from a zip. These should be identical I know, but using install.packages("RcppGSL").

Also

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

is required anytime I try to compile an Rcpp file that uses the library.

I'm not sure why, but I can use the library at least.

Dirk thank you for your help. I will go over the tutorial on R-extensions to see if I can figure out what is going on.

steve3051980
  • 129
  • 3