[Rcpp-devel] Configuring GSL headers and library for RcppGSL use on windows

Silkworth,David J. SILKWODJ at airproducts.com
Fri Jul 6 02:21:10 CEST 2012

Thanks for quick reply, Dirk.  I proceeded to create a LIB_GSL variable in my Windows environment and set it =C:\GnuWin32 per the installation I originally discussed.  On a quick check of the RcppGSLExample package included in the RcppGSL source package: R CMD check RcppGSLExample I originally got error messages indicating that gsl/gsl_vector.h could not be found.  I reversed the slash in my LIB_GSL variable definition (then another reboot of my computer) and I got passed that library problem.

Now my cmd.exe run fails with a windows message box:
 Rterm.exe - Unable To Locate Component
"This application has failed to start because libgsl.dll was not found.  Re-installing the application may fix this problem."

A press of OK lets the cmd window finish its installation check, which indicates an ERROR and report on failed installation of the RcppGSLExample package.

There is a sentence in the Description of GSL for Windows at the download site I previously referenced that states:
"If you will be using one of the dynamic libraries, add GSL_DLL to the list of predefined macros; so for use with Mingw / GCC, add -DGSL_DLL"

I get the impression  that we should have a suitable Mingw build here.  The libgsl.dll is in the \bin folder under my LIB_GSL location.  In the \lib folder there are libgsl.a,libgsl.dll.a and a txt file libgsl.def.

The libgsl.def is a long file starting with . . .


and going through the list of modules that each appear to have a corresponding header gsl_xxxx.h file.

I added the "-DGSL_DLL" to this list (gosh, what other list could be the "list of pre-defined macros" be?)
 AND I copied the file libgsl.dll found in the \bin folder as an addition to the \lib folder.

No apparent change occurred on the R CMD check RcppGSLExample.  Same crash of Rterm.exe with same error in the 00install.out report:

** testing if installed package can be loaded
Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared object 'C:/RcppPack/RcppGSLExample.Rcheck/RcppGSLExample/libs/i386/RcppGSLExample.dll':
  LoadLibrary failure:  The specified module could not be found.

-----Original Message-----
From: Dirk Eddelbuettel [mailto:edd at debian.org] 
Sent: Thursday, July 05, 2012 3:59 PM
To: Silkworth,David J.
Cc: rcpp-devel at lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Configuring GSL headers and library for RcppGSL use on windows

On 5 July 2012 at 19:42, Silkworth,David J. wrote:
| I have installed the GSL setup file " Complete package, except sources 	Setup	  6476814 	11 July 2006" from
| http://gnuwin32.sourceforge.net/packages/gsl.htm

Has that been built with MinGW so that you can use it with R?  Else you may
be wasting your time.  Matching compilers matter ...

| The Vignette says "We may need to find the location of the GSL headers and library, and this done easily from a configure source script which autoconf generates from a configure.in source file such as the following:"

That was written for the OS that typically uses configure, ie not Windows.

| I think this autoconf program relates specifically to a Linux environment.  Windows seems to know nothing of the sort.

| Then the Vignette continues with:
| "
| Similarly, the configure.win for windows can be written as:
| GSL_CFLAGS=`${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -e "RcppGSL:::CFlags()"`
| GSL_LIBS=`${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -e "RcppGSL:::LdFlags()"`
| RCPP_LDFLAGS=`${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -e "Rcpp:::LdFlags()"`
| sed -e "s|@GSL_LIBS@|${GSL_LIBS}|" n
| -e "s|@GSL_CFLAGS@|${GSL_CFLAGS}|" n
| src/Makevars.in > src/Makevars.win
| "
| Now, honestly guys, I've mastered a number of tasks so that I can build and check Rcpp and RcppArmadillo packages on both Windows and Linux.  But I am now stumped with what to do with this configure.win file.  Some of us really need hand holding.  Sorry I had to ask.

You may want to ignore the Linux stuff which makes things work on Linux where
certain assumptions can be made.  On Windows, almost all bets are off.
RcppGSL itself uses this two-line Makevars.win:

   ## This assumes that the LIB_GSL variable points to working GSL libraries
   PKG_CPPFLAGS=-I$(LIB_GSL)/include -I../inst/include
   PKG_LIBS=-L$(LIB_GSL)/lib -lgsl -lgslcblas $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")

which takes advantage of the fact that by "convention" (for lack of a better
term) CRAN and related hosts have copies of the GLS headers and libraries in
a directory pointed to by the LIB_GSL variable.

You could do the same, eg use a variable LIB_GSL.


Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  

More information about the Rcpp-devel mailing list