I am trying to install rJava within R-Studio but the error
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’
* removing ‘/Users/iMacLinda/Library/R/3.3/library/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
R
version _ platform x86_64-apple-darwin16.1.0 arch x86_64 os
darwin16.1.0 system x86_64, darwin16.1.0 status major 3 minor 3.2 year
2016 month 10 day 31 svn rev 71607 language R version.string R version
3.3.2 (2016-10-31) nickname Sincere Pumpkin Patch
How can I fix this linker error?
I have found solution elsewhere with MacPorts, steps 1-5 guided by here and steps 6 guided by here.
As root (sudo bash), edit /opt/local/Library/Frameworks/R.framework/Resources/etc/Makeconf
and change the line LIBS = -llzma -lm -liconv -licuuc -licui18n
to LIBS = -llzma -lm -liconv
install the original 1.6 Mac Java
run export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
R CMD javareconf
Now you can start R and do install.packages("rJava")
.
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
There is a solution for this with Anaconda here. The problem was with the path variable so perhaps this could solve the problem here as well. I outline the solution below about how it could be solved here.
Clean up your path
Check up your config settings
R CMD config --ldflags
-L/Users/osx/anaconda3/lib/R/lib -lR -lpcre -llzma -lbz2 -lz -lm -liconv -licuuc -licui18n
Test this mv ~/.bash_profile ~/.bash_profile_backup
.
Restart your terminal.
Now the environment variables in R should be different
$ R CMD config --ldflags
-F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv
Run the following
sudo R CMD javareconf
Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
If you was able to install rJava, the problem was in your path otherwise try alternative solutions.
Alternative solution with Homebrew
There is also a solution for this with Homebrew here where R is installed with brew cask install r-app
and gcc had to be recompiled without a forenmp flag.