简体   繁体   中英

Trouble installing rJava on Mac ; trouble with JNI data types

RESOLVED!!

See my solution below, in case this question helps others in the future.

Error

As the title described, it it failing for me. The error I'm receiving, when I attempt to install.packages('rJava') from inside R is (with some preceding good checks):

checking whether JNI programs can be compiled... yes
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/local/lib/R/3.2/site-library/rJava’

Fix Attempts

I have checked and tried the following resolutions, none of which worked for me:

No such luck, with any of these attempts.


I had previously had rJava (and RJDBC ) installed properly.

[Edit: I later found out, the actual problem was upgrading to OS X 10.11, El Capitan.]


Configuration

$ java -version
java version "1.8.0_45"

> R.Version()
$platform
[1] "x86_64-apple-darwin15.0.0"
$version.string
[1] "R version 3.2.2 (2015-08-14)"

Mac OS itself:

System Version: OS X 10.11.1 (15B42)

I did not do the LD_LIBRARY_PATH, as it did not seem relevant to a Mac

Yes, but a Mac has DYLD_LIBRARY_PATH . If you link with -ljvm you have to have the directory containing libjvm.dylib in DYLD_LIBRARY_PATH .

That said, I found it more convenient to link JNI programs with -ljli (in lib/jli ), because the programs linked with -ljvm will open a prompt to install Apple's own Java runtime when the system doesn't have it (at least they did on my and our customers' systems some while ago).

Edit: here's a link to the dyld documentation

I finally resolved this, via a solution I found here .

The new Mac OS X (10.11, El Capitan) has trouble with env variables.


The newest dev flavor of rJava manages to handle things correctly. Here is what I did to resolve it:

  1. Download version 0.9-8 ( rJava_0.9-8.tar.gz ) from here
  2. Install it from the downloaded source:

    $ R CMD INSTALL ~/Downloads/rJava_0.9-8.tar.gz

(Or wherever you put it)

That's all it took!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM