title: rJava linker error licuuc with Anaconda & fopenmp error without Anaconda for macOS Sierra 10.12.4
body: <p>I want to install rJava on macOS Sierra 10.12.4. My current Java version is <code>Java version: 1.8.0_131</code>, according to <code>R CMD javareconf|grep version</code>. I have installed Java with Homebrew's cask. </p>
  
  <p>My Java runs the following </p>
  
  <pre><code>$ java -version
  java version "1.8.0_131"
  Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
  Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
  </code></pre>
  
  <p>My R version is </p>
  
  <pre><code>R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
  Copyright (C) 2016 The R Foundation for Statistical Computing
  Platform: x86_64-apple-darwin11.4.2 (64-bit)
  </code></pre>
  
  <p>R Java config runs such that</p>
  
  <pre><code>$ R CMD javareconf
  Java interpreter : /usr/bin/java
  Java version     : 1.8.0_131
  Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
  Java compiler    : /usr/bin/javac
  Java headers gen.: /usr/bin/javah
  Java archive tool: /usr/bin/jar
  Non-system Java on macOS
  
  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
  During startup - Warning messages:
  1: Setting LC_COLLATE failed, using "C" 
  2: Setting LC_TIME failed, using "C" 
  3: Setting LC_MESSAGES failed, using "C" 
  4: Setting LC_MONETARY failed, using "C" 
  clang -I/Volumes/osx/201705_anaconda/anaconda/lib/R/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin -I/Volumes/osx/201705_anaconda/anaconda/include    -fPIC  -I/Volumes/osx/201705_anaconda/anaconda/include  -c conftest.c -o conftest.o
  clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Volumes/osx/201705_anaconda/anaconda/lib/R/lib -arch x86_64 -L/Volumes/osx/201705_anaconda/anaconda/lib -lgfortran -L/Volumes/osx/201705_anaconda/anaconda -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -ljvm -L/Volumes/osx/201705_anaconda/anaconda/lib/R/lib -lR -lintl -liconv -lc -Wl,-framework -Wl,CoreFoundation
  
  
  JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
  Java library path: $(JAVA_HOME)/lib/server
  JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
  JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
  Updating Java configuration in /Volumes/osx/201705_anaconda/anaconda/lib/R
  Done.
  </code></pre>
  
  <p>which looks to be properly set-up as guided <a href="https://github.com/s-u/rJava/issues/36#issuecomment-121871755" rel="nofollow noreferrer">here</a> and this SO thread <a href="https://stackoverflow.com/questions/17570586/unable-to-compile-jni-program-rjava">unable to compile JNI program rJava</a> so the JDK looks to be correctly installed.</p>
  
  <p>I get the linker error with the command <code>install.packages("rJava")</code></p>
  
  <pre><code>checking Java support in R... present:
  interpreter : '/usr/bin/java'
  archiver    : '/usr/bin/jar'
  compiler    : '/usr/bin/javac'
  header prep.: '/usr/bin/javah'
  cpp flags   : '-I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/../include/darwin'
  java libs   : '-L/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server -ljvm'
  ...
  ld: library not found for -licuuc
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[2]: *** [libjri.jnilib] Error 1
  make[1]: *** [src/JRI.jar] Error 2
  make: *** [jri] Error 2
  ERROR: compilation failed for package ‘rJava’
  </code></pre>
  
  <p>I have got the same error despite Java sources: official JDK and Homebrew's Java return the same linker/library error.</p>
  
  <h2><strong>What could be causing this linker/library licuuc error with Anaconda and how to fix it?</strong></h2>
  
  <p><em>Old threads</em></p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/40572179/install-rjava-on-macos-sierra-10-12-1-linker-error-licuuc">Install rJava on macOS Sierra 10.12.1: linker error licuuc</a>: a solution candidate with MacPorts</p></li>
  <li><p><a href="https://stackoverflow.com/questions/44383668/rjava-on-macos-sierra-10-12-15-unsupported-option-fopenmp">rJava on MacOS Sierra 10.12.15: unsupported option fopenmp</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/30738974/rjava-load-error-in-rstudio-r-after-upgrading-to-osx-yosemite">rJava load error in RStudio/R after &quot;upgrading&quot; to OSX Yosemite</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/26755013/install-xlsx-and-rjava-on-macos-mavericks-10-9-5">Install xlsx and rJava on macOS Mavericks 10.9.5</a></p></li>
  </ol>
  
  <p><strong>Fixes that I have tried</strong></p>
  
  <ol>
  <li><p><code>options("java.home")</code> returns NULL so <code>options("java.home"="/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/")</code> as guided by <a href="https://stackoverflow.com/q/30738974/164148">here</a></p></li>
  <li><p>Unistalled Homebrew's Java and replaced it with Oracele's Java and JDK <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html" rel="nofollow noreferrer">here</a>: the same licuuc library/linker error persists. I tried <code>sudo Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'</code> guided by <a href="https://stackoverflow.com/a/40640416/164148">this</a> but the same <code>licuuc library not found</code> error.</p></li>
  <li><p>Updated macOS from El Capitan 10.11.6 to Sierra 10.12.4 but the same licuuc library/linker error persists.</p></li>
  <li><p><em>Running without sudo, javac missing (following this <a href="https://stackoverflow.com/a/44488810/164148">here</a> and this <a href="https://stackoverflow.com/a/42009476/164148">here</a>). This error may be easiest to fix with pointing the javac directory there to <code>/usr/bin/javac</code> but better solution? When I run it with sudo, I got the same licuuc error.</em></p>
  
  <pre><code>R CMD javareconf -e LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_LD_LIBRARY_PATH
  
  Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
  
  Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/javac"
  (-1)
      make[2]: *** [org/rosuda/JRI/Rengine.class] Error 2
      make[1]: *** [src/JRI.jar] Error 2
      make: *** [jri] Error 2
      ERROR: compilation failed for package ‘rJava’
  </code></pre></li>
  <li><p>After removal of Anaconda <code>conda install anaconda-clean; anaconda-clean --yes; rm -rf ~/anaconda</code>, guided <a href="https://docs.continuum.io/anaconda/install/uninstall" rel="nofollow noreferrer">here</a>, and installing R with cask such that <code>brew cask install r-app; sudo R CMD javareconf; Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'</code> so getting a new error</p>
  
  <pre><code>clang: error: unsupported option '-fopenmp'
  make[2]: *** [libjri.jnilib] Error 1
  make[1]: *** [src/JRI.jar] Error 2
  make: *** [jri] Error 2
  ERROR: compilation failed for package ‘rJava’
  </code></pre></li>
  </ol>
  
  <h2><strong>What could be causing this error forenmp without Anaconda and how to fix it?</strong></h2>