[R-SIG-Mac] rJava compilation on R 3.5 devel [NOt completely SOLVED]
Marc Girondot
marc.girondot at u-psud.fr
Wed Jan 31 20:48:55 CET 2018
Hi Simon,
Half solution ! Thanks !
I remove JAVA_HOME and when R is ran as root or non-root in terminal,
rJava package can be loaded. Great !
But in Rstudio, I have still a problem (see bellow).
Any suggestion ?
Thanks
Marc
> library(rJava)
Erreur : package or namespace load failed for ‘rJava’:
.onLoad a échoué dans loadNamespace() pour 'rJava', détails :
appel : dyn.load(file, DLLpath = DLLpath, ...)
erreur : impossible de charger l'objet partagé
'/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so,
6): Library not loaded: @rpath/libjvm.dylib
Referenced from:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
Here are the Sys.getenv() in the 3 cases (terminal R, root or not, and
Rstudio):
Rstudio
DYLD_FALLBACK_LIBRARY_PATH
/Library/Frameworks/R.framework/Resources/lib:/Library/Frameworks/R.framework/Resources/lib:/Users/marcgirondot/lib:/usr/local/lib:/usr/lib::::
DYLD_LIBRARY_PATH
/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server
R (in terminal, non-root)
DYLD_FALLBACK_LIBRARY_PATH
/Library/Frameworks/R.framework/Resources/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server
R (in terminal, root)
DYLD_FALLBACK_LIBRARY_PATH
/Library/Frameworks/R.framework/Resources/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server
Le 31/01/2018 à 19:49, Simon Urbanek a écrit :
> It means that you are likely setting JAVA_HOME incorrectly in your user account. Don't set JAVA_HOME - you'll only likely break things by doing so.
>
> Cheers,
> Simon
>
>
>
>> On Jan 31, 2018, at 10:52 AM, Marc Girondot <marc.girondot at u-psud.fr> wrote:
>>
>> Thanks for your help:
>>
>> Here are some results; First in terminal:
>>
>> belinda:~ marcgirondot$ locate libjvm.dylib
>> /Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/itms/java/lib/server/libjvm.dylib
>> /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/server/libjvm.dylib
>> /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjvm.dylib
>> /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/server/libjvm.dylib
>> /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib
>> /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server/libjvm.dylib
>>
>> Now in R as non-root:
>>
>>> Sys.getenv()
>> DYLD_FALLBACK_LIBRARY_PATH
>> /Library/Frameworks/R.framework/Resources/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/lib/server
>>
>> The path of DYLD_FALLBACK_LIBRARY_PATH is wrong. This folder does not exist.
>>
>> And in R as root
>>> Sys.getenv()
>> DYLD_FALLBACK_LIBRARY_PATH
>> /Library/Frameworks/R.framework/Resources/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server
>>
>> The path is correct
>>
>> Strange... but no solution still
>>
>> Marc
>>
>>
>> Le 31/01/2018 à 14:39, Keith O'Hara a écrit :
>>> Seems odd that R can’t find libjvm outside of sudo.
>>>
>>> From R, run
>>>
>>> Sys.getenv()
>>>
>>> and check your DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH variables. Should be ‘[..]/Home/jre/lib/server’ in there somewhere. Check those paths for libjvm.dylib
>>>
>>>> On Jan 31, 2018, at 8:17 AM, Marc Girondot <marc.girondot at u-psud.fr> wrote:
>>>>
>>>> Sorry... bad news. It works only if R is ran as root. If R is ran as non-root user:
>>>>
>>>>> library(rJava)
>>>> Erreur : package or namespace load failed for ‘rJava’:
>>>> .onLoad a échoué dans loadNamespace() pour 'rJava', détails :
>>>> appel : dyn.load(file, DLLpath = DLLpath, ...)
>>>> erreur : impossible de charger l'objet partagé '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
>>>> dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib
>>>> Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
>>>> Reason: image not found
>>>>
>>>> I will continue to investigate.
>>>>
>>>> Sorry for this wrong news !
>>>>
>>>> Marc
>>>>
>>>>
>>>> Le 31/01/2018 à 14:03, Marc Girondot via R-SIG-Mac a écrit :
>>>>> I have found a solution based on the proposition of Keith. Thanks a lot
>>>>>
>>>>> ############
>>>>>
>>>>> First I have made some cleaning because I had pieces of clang in many places.
>>>>>
>>>>> Then with a clean version I installed clang-4.0.0-darwin15.6-Release.tar.gz using the version in
>>>>> http://r.research.att.com/libs/clang-4.0.0-darwin15.6-Release.tar.gz
>>>>>
>>>>> Note that it produced an error at the end when I run the command:
>>>>> sudo tar xvzf clang-4.0.0-darwin15.6-Release.tar.gz -C /
>>>>> The error is:
>>>>> tar: Error exit delayed from previous errors.
>>>>>
>>>>> But it seems to be ok
>>>>>
>>>>> then I create the link as propose by Keith:
>>>>> cd /usr/local/lib
>>>>> sudo ln -s /usr/local/clang4/lib/libomp.dylib libomp.dylib
>>>>>
>>>>> And it works perfectly if the install.packages("rJava") is ran as root: sudo R
>>>>>
>>>>> ######################
>>>>>
>>>>> Now, let try with clang 5.0.1 from homebrew.
>>>>>
>>>>> First I delete all tracks of previous installation of clang4:
>>>>> sudo cd <folder where is clang-4.0.0-darwin15.6-Release.tar.gz)>
>>>>> # I use this trick to enter the root password firsttime; after it does not ask within the loop
>>>>> for file in $(tar tfz clang-4.0.0-darwin15.6-Release.tar.gz); do
>>>>> sudo rm -f /$file;
>>>>> done
>>>>>
>>>>> # Remove empty _folders_ associated with the binary
>>>>> for file in $(tar tfz clang-4.0.0-darwin15.6-Release.tar.gz); do
>>>>> sudo rmdir -p /$file;
>>>>> done
>>>>>
>>>>> Then I install llvm with homebrew:
>>>>> brew install llvm
>>>>>
>>>>> in /usr/local/opt/llvm/lib there is no libomp.dylib but libgomp.dylib and libiomp5.dylib. I don't know if I can use it instead of libomp.dylib.
>>>>>
>>>>> But I see one in:
>>>>> /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libomp.dylib
>>>>>
>>>>> Better to use this one:
>>>>> cd /usr/local/lib
>>>>> sudo ln -s /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libomp.dylib libomp.dylib
>>>>>
>>>>>
>>>>> And the compilation ran correctly.
>>>>>
>>>>> Thanks a lot !
>>>>>
>>>>> Marc
>>>>>
>>>>> Le 31/01/2018 à 11:52, Keith O'Hara a écrit :
>>>>>> Sorry, ignore the installation question, I missed the ‘brew install’ line.
>>>>>>
>>>>>> Try adding a symbolic link from the brew install of libomp to /usr/local/lib.
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On Jan 31, 2018, at 5:38 AM, Keith O'Hara <keith.ohara at nyu.edu> wrote:
>>>>>>>
>>>>>>> Apple’s LLVM doesn’t support OpenMP, which explains the second error.
>>>>>>>
>>>>>>> How did you install clang-5.0.1? If you installed using MacPorts, then you might need to create a symbolic link to libomp in /usr/local/lib. Check if the following exists:
>>>>>>>
>>>>>>> /opt/local/lib/libomp/libomp.dylib
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> On Jan 31, 2018, at 5:22 AM, Marc Girondot via R-SIG-Mac <r-sig-mac at r-project.org> wrote:
>>>>>>>>
>>>>>>>> Dear Experts,
>>>>>>>>
>>>>>>>> I use now r-3.5 devel as it is stable (from http://r.research.att.com , version (2018/01/30, r74185) ) but I have a problem with compilation of rJava package.
>>>>>>>>
>>>>>>>> In short (all the explanations are bellow):
>>>>>>>>
>>>>>>>> If I use clang 4.0.0 from here: http://r.research.att.com/libs/, I get this error: ld: library not found for -lomp
>>>>>>>>
>>>>>>>> If I use clang from xcode, I get this error: clang: error: unsupported option '-fopenmp'
>>>>>>>>
>>>>>>>> If I use clang 5.0.1, I get this error: ld: library not found for -lomp
>>>>>>>>
>>>>>>>> Any idea to have rJava in r-devel ?
>>>>>>>>
>>>>>>>> Thanks a lot
>>>>>>>>
>>>>>>>> Marc
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> First I ran:
>>>>>>>>
>>>>>>>> sudo R CMD javareconf
>>>>>>>>
>>>>>>>> I have the Java version : 1.8.0_162
>>>>>>>>
>>>>>>>> I need to compile it from source but it failed with clang4 reporting an error.
>>>>>>>>
>>>>>>>> I try various origin of clang:
>>>>>>>>
>>>>>>>> at the beginning of the compilation, it said:
>>>>>>>>
>>>>>>>> checking for gcc... /usr/local/clang4/bin/clang
>>>>>>>>
>>>>>>>> I tried several version of clang:
>>>>>>>>
>>>>>>>> belinda:local marcgirondot$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --version
>>>>>>>> Apple LLVM version 9.0.0 (clang-900.0.39.2)
>>>>>>>> Target: x86_64-apple-darwin17.3.0
>>>>>>>> Thread model: posix
>>>>>>>> InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
>>>>>>>>
>>>>>>>> or (same version installed by: brew install llvm )
>>>>>>>>
>>>>>>>> belinda:local marcgirondot$ /Applications/clang+llvm-5.0.1-final-x86_64-apple-darwin/bin/clang --version
>>>>>>>> clang version 5.0.1 (tags/RELEASE_501/final)
>>>>>>>> Target: x86_64-apple-darwin17.3.0
>>>>>>>> Thread model: posix
>>>>>>>> InstalledDir: /Applications/clang+llvm-5.0.1-final-x86_64-apple-darwin/bin
>>>>>>>>
>>>>>>>> or
>>>>>>>>
>>>>>>>> belinda:local marcgirondot$ /usr/local/clang4/bin/clang --version
>>>>>>>> clang version 4.0.0 (tags/RELEASE_400/final)
>>>>>>>> Target: x86_64-apple-darwin17.3.0
>>>>>>>> Thread model: posix
>>>>>>>> InstalledDir: /usr/local/clang4/bin
>>>>>>>>
>>>>>>>> If I use the former, I get this error:
>>>>>>>> /usr/local/clang4/bin/clang -o libjri.jnilib Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o -dynamiclib -framework JavaVM -fopenmp -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv
>>>>>>>> ld: library not found for -lomp
>>>>>>>> clang-4.0: 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’
>>>>>>>>
>>>>>>>> Then I tried more recent versions:
>>>>>>>>
>>>>>>>> I make a symbolic link to clang 5.0.1 or the one within xcode:
>>>>>>>> cd /usr/local
>>>>>>>> sudo ln -s /Applications/clang+llvm-5.0.1-final-x86_64-apple-darwin clang4
>>>>>>>>
>>>>>>>> I get this error: (after running sudo R and within R: install.packages("rJava")
>>>>>>>> /usr/local/clang4/bin/clang -o libjri.jnilib Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o -dynamiclib -framework JavaVM -fopenmp -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv
>>>>>>>> ld: library not found for -lomp
>>>>>>>> clang-5.0: 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’
>>>>>>>>
>>>>>>>>
>>>>>>>> If I make the symbolic link to
>>>>>>>> cd /usr/local
>>>>>>>> sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr clang4
>>>>>>>>
>>>>>>>> I get this error: (after running sudo R and within R: install.packages("rJava")
>>>>>>>> /usr/local/clang4/bin/clang -o libjri.jnilib Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o -dynamiclib -framework JavaVM -fopenmp -L/usr/local/lib -F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv
>>>>>>>> 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’
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> R-SIG-Mac mailing list
>>>>>>>> R-SIG-Mac at r-project.org
>>>>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>>> _______________________________________________
>>>>> R-SIG-Mac mailing list
>>>>> R-SIG-Mac at r-project.org
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>> --
>>>> __________________________________________________________
>>>> Marc Girondot, Pr
>>>>
>>>> Laboratoire Ecologie, Systématique et Evolution
>>>> Equipe de Conservation des Populations et des Communautés
>>>> CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
>>>> Bâtiment 362
>>>> 91405 Orsay Cedex, France
>>>>
>>>> Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53
>>>> e-mail: marc.girondot at u-psud.fr
>>>> Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
>>>> Skype: girondot
>>>>
>> --
>> __________________________________________________________
>> Marc Girondot, Pr
>>
>> Laboratoire Ecologie, Systématique et Evolution
>> Equipe de Conservation des Populations et des Communautés
>> CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
>> Bâtiment 362
>> 91405 Orsay Cedex, France
>>
>> Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53
>> e-mail: marc.girondot at u-psud.fr
>> Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
>> Skype: girondot
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
--
__________________________________________________________
Marc Girondot, Pr
Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France
Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53
e-mail: marc.girondot at u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot
More information about the R-SIG-Mac
mailing list