我最近从32位笔记本换成了64位台式机(都是win7)。我刚刚发现使用加载 dll 时出现错误dyn.load
。我想这是一个简单的错误,我忽略了一些事情。
例如,我编写了这个简单的 c 函数(foo.c):
void foo( int *x) {*x = *x + 1;}
然后在命令提示符下编译:
R CMD SHLIB foo.c
然后在 32 位 R 中我可以在 R 中使用它:
> dyn.load("foo.dll")
> .C("foo",as.integer(1))
[[1]]
[1] 2
但在 64 位 R 中我得到:
> dyn.load("foo.dll")
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/Sacha/Documents/R/foo.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
nd.
Edit:
作为参考,可以通过使用在架构中强制 R CMD--arch 64x
:
R --arch x64 CMD SHLIB foo.c
实际上很清楚,我知道我犯了一个菜鸟错误:)
我的猜测是您正在将其编译为 32 位目标。您需要使用 64 位工具在 64 位机器上构建它。您无法将 32 位 DLL 加载到 64 位进程中,反之亦然。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)