问题描述
我对 Windows 开发几乎一无所知.我编写了一个在 Linux 上运行良好的 R 包.我试图让它在 Windows 上工作.不幸的是,我觉得我只是撞墙了.该包使用 GSL 库.我做的第一件事是使用 mingw-w64 编译它,它按预期工作.然后我继续构建包.一切都很顺利,直到 R 测试包是否可以加载.我收到此错误消息:
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".
我不明白为什么这会失败.这是生成 dll 的行:
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
其中 x86_64-w64-mingw32-gcc
来自 Rtools.Bayes.mix.biv.reg.dll 怎么可能不是有效的 Win32 应用程序?
where x86_64-w64-mingw32-gcc
is from Rtools. How can Bayes.mix.biv.reg.dll not be a valid Win32 application?
推荐答案
您可以遵循 RcppGSL 附带的示例包,即使不打算使用 Rcpp 或 RcppGSL.
You could follow the example package included with RcppGSL, even if don't plan on using Rcpp or RcppGSL.
## 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.
这篇关于在 Windows 上构建使用 GSL 的 R 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!