0

I’m running into issues while trying to install the rJava package on my Mac. I have tried the solutions proposed online, including running R CMD javareconf, but without success (output is below). Any advice on how to fix this issue would be much appreciated.

Among the things I tried is the solution proposed here: rJava installation fails on macOS 10.14

open macOS_SDK_headers_for_macOS_10.14.pkg```

This had worked for me with my previous Mac, but not this time.

Output of:

```sudo R CMD javareconf```

Java interpreter : /usr/bin/java
Java version     : 12.0.2
Java home path   : /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
/usr/local/Cellar/gcc/9.1.0/bin/gcc-9 -I"/usr/local/Cellar/r/3.6.1/lib/R/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/include/darwin  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include  -fPIC  -g -O2  -c conftest.c -o conftest.o
/usr/local/Cellar/gcc/9.1.0/bin/gcc-9 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.6.1/lib/R/lib -L/usr/local/Cellar/gcc/9.1.0/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/lib/server -ljvm -L/usr/local/Cellar/r/3.6.1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lintl
collect2: error: ld returned 1 exit status
make: *** [conftest.so] Error 1
Unable to compile a JNI program


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
Java library path: 
JNI cpp flags    : 
JNI linker flags : 
Updating Java configuration in /usr/local/Cellar/r/3.6.1/lib/R
Done.
Noe
  • 1
  • https://stackoverflow.com/a/20044813/7590064 – Not_Dave Jul 30 '19 at 18:10
  • I have gsl installed (version 2.5). I think above references is a fix for ```ld: library not found for -lgsl``` – Noe Jul 31 '19 at 12:28
  • whereas I have ```ld: library not found for -lintl``` – Noe Jul 31 '19 at 12:28
  • Reinstalling R solved the problem for me. Sounds like some libraries must be in place before R is installed for the corresponding paths to be recognized. I also had to change the content of /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so to point to correct jdk. It was pointing to jdk-11 even though my installation was always jdk-12. – Noe Jul 31 '19 at 22:06

0 Answers0