[英]Building an R package that uses the GSL on Windows
I have little to no knowledge about developing for Windows. 我对Windows开发几乎一无所知。 I have written an R package that works just fine on Linux.
我已经写了一个R包,可以在Linux上正常工作。 I am trying to get it to work on Windows.
我正在尝试使其在Windows上运行。 Unfortunately, I feel I just hit a wall.
不幸的是,我觉得我撞墙了。 The package uses the GSL library.
该软件包使用GSL库。 The first thing I did was to compile it using mingw-w64, which worked as expected.
我要做的第一件事是使用mingw-w64进行编译,该工作按预期进行。 I then proceeded to build the package.
然后,我继续构建软件包。 Everything went fine up until when R tests if the package can be loaded.
一切顺利,直到R测试是否可以加载软件包为止。 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:
这是生成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. 其中
x86_64-w64-mingw32-gcc
来自Rtools。 How can Bayes.mix.biv.reg.dll not be a valid Win32 application? Bayes.mix.biv.reg.dll不能成为有效的Win32应用程序吗?
You could follow the example package included with RcppGSL, even if don't plan on using Rcpp or RcppGSL. 即使不打算使用Rcpp或RcppGSL,也可以遵循RcppGSL附带的示例程序包 。
It has this in its src/Makevars.win 它在它的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. 与其他软件包一样,此处的关键是您确实非常希望依赖于预构建的库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.