I recently switched from a 32-bit laptop to a 64-bit desktop (both win7). I just found out that when I load a dll using dyn.load I get an error. I assume this is a simple mistake, and I'm missing something.
For example, I write this simple function c (foo.c):
void foo( int *x) {*x = *x + 1;}
Then compile it on the command line:
R CMD SHLIB foo.c
Then in 32bit R I can use it in R:
> dyn.load("foo.dll") > .C("foo",as.integer(1)) [[1]] [1] 2
but in 64 bit R I get:
> 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:
For reference, R CMD can be forcibly used in the architecture with --arch 64x :
R --arch x64 CMD SHLIB foo.c
Clearly, I knew that I was making an abusive mistake :)
Sacha epskamp
source share