Search code examples
packager-forge

build R package failing with rJava LoadLibrary "not a valid win32 application" failure


I wrote an R package to connect R with messageQueues, specifically activeMQ and rabbitMQ, so all the source can be found here: http://r-forge.r-project.org/projects/r-message-queue/

r-forge fails to build the package, so I'm recreating/debugging locally, but my local build fails earlier in the process than r-forge.

I'm running 64bit windows7, 64bit R v2.15.2.
If I'm going about this the wrong way, let me know.

BUILDING the R package

$ R --verbose CMD build messageQueue
* checking for file 'messageQueue/DESCRIPTION' ... OK
* preparing 'messageQueue':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'messageQueue_0.1.tar.gz'
cygwin warning:
  MS-DOS style path detected: C:/Users/msm336/workspace_r/messageQueue_0.1.tar.gz
  Preferred POSIX equivalent is: /cygdrive/c/Users/msm336/workspace_r/messageQueue_0.1.tar.gz
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

CHECKING the R package

$ R --verbose CMD check messageQueue_0.1.tar.gz
* using log directory 'C:/Users/msm336/workspace_r/messageQueue.Rcheck'
* using R version 2.15.2 (2012-10-26)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'messageQueue/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'messageQueue' version '0.1'
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking whether package 'messageQueue' can be installed ... ERROR
Installation failed.
See 'C:/Users/msm336/workspace_r/messageQueue.Rcheck/00install.out' for details.

CONTENTS of messageQueue.Rcheck/00install.out

* installing *source* package 'messageQueue' ...
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Program Files/R/R-2.15.2/library/rJava/libs/i386/rJava.dll':
  LoadLibrary failure:  %1 is not a valid Win32 application.

Error : package 'rJava' could not be loaded
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/msm336/workspace_r/messageQueue.Rcheck/messageQueue'

I'm not sure why it's trying to load the i386 version of rJava, when I'm running x64 R on Windows7 x64 using a 64bit version of java:

$ java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b22)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)

I've also got the JAVA_HOME/jre/bin/server/jvm.dll on my path, because rJava likes that somehow.

Any help would be greatly appreciated.

Thanks,

Matt.


Solution

  • By default, R's check function will try to test the package against all relevant architectures. On a windows7 x64 machine, this means it will try testing the package against both i386 and x64.

    Unfortunately, when running R x64 with a x64 JDK, it seems to not manage architecture dependencies cleanly, thus tries to load a i386 DLL (/rJava/libs/i386/rJava.dll) within an x64 context and fails. I don't fully understand why, but can work around it.

    Forcing R CMD check messageQueue to run against the current (default) architecture can be done using the --no-multiarch switch. It is documented in the Writing R Extensions manual, Section 1.3.1 (see: Multiple sub-architectures near the end).

    My updated R command to check only against the current architecture:

    R --verbose CMD check --no-multiarch messageQueue_0.1.tar.gz
    

    Awesome.