I provide the solution in two ways: Anaconda and the Brew way. I suggest you to use the Brew solution. In both cases, I have Oracle's JDK installed and if you do this, remember reconfigure Java for R with sudo R CMD javareconf
.
Anaconda (solution to the licuuc error)
A similar linker error occurred here. The anaconda path messes things up as
$ R CMD config --ldflags
-L/Users/osx/anaconda3/lib/R/lib -lR -lpcre -llzma -lbz2 -lz -lm -liconv -licuuc -licui18n
so remove a path like below from ~/.bash_profile
export PATH="/Users/osx/anaconda3/bin:$PATH" #Removed to install rJava
so we should get something like
$ R CMD config --ldflags
-F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv
and after this rJava can be installed even with Anaconda with
sudo R CMD javareconf
Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
congratulations!
Brew (solution to fopenmp error)
Your R installation should be done with Homebrew cask such that
brew cask install r-app
where brew's r package is not enough for this. Shortly, the forenmp problem is in the compiler not having the flag so we have to recompile the compiler. This solution is explained more thoroughly here. The problem in the question is for 3.3.* R and gcc solution used such that
#xcode-select --install #if Xcode commandline tools not installed
brew install homebrew/versions/gcc49 --without-multilib #Long ~70min compiling...
sudo chown -R $(whoami):admin /usr/local
brew link --overwrite --force gcc49
brew unlink gcc49 && brew link gcc49
brew install llvm
mkdir ~/.R; touch ~/.R/Makevars
echo "VER=-4.9
CC=gcc$(VER)
CXX=g++$(VER)
CXX1X=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/4.9.3/lib/gcc/4.9" > ~/.R/Makevars
and now
sudo R CMD javareconf
Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
and now rJava
is working!
Solutions here mentioned also in the following because of similar problems
Install rJava on macOS Sierra 10.12.1: linker error licuuc
rJava on MacOS Sierra 10.12.15: unsupported option fopenmp
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…