pfournier
pfournier

Reputation: 31

Building an R package that uses the GSL on Windows

I have little to no knowledge about developing for Windows. I have written an R package that works just fine on Linux. I am trying to get it to work on Windows. Unfortunately, I feel I just hit a wall. The package uses the GSL library. The first thing I did was to compile it using mingw-w64, which worked as expected. I then proceeded to build the package. Everything went fine up until when R tests if the package can be loaded. I get this error message:

Error in inDL(x, as.logical(local), as.logical(now), ...) :
  impossible de charger l'objet partagé 'C:/Users/Patrick/Desktop/r_packages/Bayes.mix.biv.reg/libs/x64/Bayes.mix.biv.reg.dll':
  LoadLibrary failure:  %1 is not a valid Win32 application.

The french part could be translated to something like "unable to load the shared object".

I don't understand why this is failing. Here is the line that produced the dll:

x86_64-w64-mingw32-gcc -shared -s -static-libgcc -o Bayes.mix.biv.reg.dll tmp.def DICWAIC.o Utils.o wrapperV11.o wrapperV11woallocations.o -LC:/PROGRA~1/R/R-3.3.3/bin/x64 -LC:/MinGW/msys/1.0/gsl/lib -lgsl -lgslcblas -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.3/bin/x64 -lR

where x86_64-w64-mingw32-gcc is from Rtools. How can Bayes.mix.biv.reg.dll not be a valid Win32 application?

Upvotes: 1

Views: 520

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368241

You could follow the example package included with RcppGSL, even if don't plan on using Rcpp or RcppGSL.

It has this in its src/Makevars.win

## This assumes that the LIB_GSL variable points to working GSL libraries
PKG_CPPFLAGS=-I$(LIB_GSL)/include
PKG_LIBS=-L$(LIB_GSL)/lib -lgsl -lgslcblas 

The key here, as with some other packages is that you really, really want to rely on the prebuilt libraries.

Upvotes: 1

Related Questions