Alex
Alex

Reputation: 4180

Trying to load a compiled C code in R using dyn.load(). Got an error message

I compiled a C code in the Terminal on a Mac (Mountain Lion). Trying to load it using dyn.load on a Windows 7 PC, I got this message:

Error in inDL(x, as.logical(local), as.logical(now), ...) : 
 unable to load shared object 'C:/Users/Iris/Desktop/mcmc.so':
 LoadLibrary failure:  %1 is not a valid Win32 application.

The Windows 7 is 64 bit, and the R on it is also 64 bit. I had no problem loading the C code on another MAC. I wonder what went wrong with my code. Thanks.

EDIT:

I tried a solution found here, but it did not work.

Upvotes: 0

Views: 345

Answers (1)

Ken Wilcox
Ken Wilcox

Reputation: 883

The Mac will compile C code to Mach-O (Mach Object) format Mach-O - Wikipedia This should work fine across the Mac platform. This is why it worked on another Mac.

Windows uses PE (Portable Executable) format WinPE - Wikipedia

The formats are not compatible, that's why LoadLibrary is complaining about not being a valid Win32 application - because it is not.

Recompile the C code on Windows and it should work.

Upvotes: 2

Related Questions