c++rgslrtools

cannot find -lgsl, cannot find -lgslcblas


I am trying to install a R package on windows 10 using "R CMD INSTALL Rpkg" and I am getting the following error:

C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgsl
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgslcblas
collect2.exe: error: ld returned 1 exit status
no DLL was created

I installed R in C:\R_soft\R\R-4.0.4, RStudio in C:\R_soft\RStudio, and Rtools in C:\rtools40. Location of gsl library is C:\R_soft\R\local323. I referred https://cran.r-project.org/web/packages/dynr/vignettes/InstallationForUsers.pdf to install gsl and setup the environmental paths. The package I am trying to install was written in C++.

> Sys.which("make")                              
"C:\\rtools40\\usr\\bin\\make.exe"

> Sys.which("gcc") 
"C:\\rtools40\\mingw64\\bin\\gcc.exe"

I am still new to R language. Any help would be highly appreciated.


Solution

  • I figured out the solution for the issue. First of all, I do not need to install a separate gsl library to use with R. So, I removed the gsl library I installed earlier into C:\R_soft\R\local323. Then I opened the msys2 shell in rtools and ran pacman -S mingw-w64-x86_64-gsl. This installs gsl library to mingw64 folder in rtools (default folder used by rtools to store C++ libraries). See https://packages.msys2.org/package/mingw-w64-x86_64-gsl for more about the gsl package information.