Problem with loading compiled c code in R x64 using dyn.load

Posted by Sacha Epskamp on Stack Overflow See other posts from Stack Overflow or by Sacha Epskamp
Published on 2011-02-06T23:12:47Z Indexed on 2011/02/06 23:25 UTC
Read the original article Hit count: 188

Filed under:
|
|

I recently went from a 32bit laptop to a 64bit desktop (both win7). I just found out that I get an error now when loading dll's using dyn.load. I guess this is a simple mistake and I am overlooking something.

For example, I write this simple c function (foo.c):

void foo( int *x) {*x = *x + 1;}

Then compile it in command prompt:

R CMD SHLIB foo.c

Then in 32bit R I can use it in R:

> setwd("R")
> dyn.load("foo.dll")
> .C("foo",as.integer(1))
[[1]]
[1] 2

but in 64bit 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.

© Stack Overflow or respective owner

Related posts about c

    Related posts about r