[R-SIG-Mac] Install rJava produce an error

Balamuta, James Joseph balamut2 at illinois.edu
Sun Oct 15 17:43:03 CEST 2017


Greetings and Salutations Marc, 

The “-fopenmp” issue indicates you are using Xcode’s clang compiler that does _not_ support OpenMP as Apple has yet to enable it in their fork of the llvm project. As of R 3.4.0, the macOS binary of _R_ uses a custom toolchain that explicitly supports OpenMP. The downside of this approach is the custom toolchain does _not_ ship with the R binary. As a result, you will need to obtain the necessary clang4 binary from http://r.research.att.com/libs/ and modify your local ~/.R/Makevars appropriately to point to this new compiler. 

To simplify the process, I’ve created an installer that automatically puts the clang4 binary in the correct place and sets up the relevant paths for ~/.R/Makevars. 

This installer can be found here:

https://uofi.box.com/v/r-macos-clang-pkg

The source code used to create the installer is publically available here:

https://github.com/coatless/r-macos-clang 

The latest version of the installer is developer signed thanks to a financial contribution by Professor Timothy Bates (http://www.ed.ac.uk/profile/timothy-bates) of the University of Edinburgh that allowed me to join the Apple Developer program. 

If you are interested in learning more about enabling OpenMP on macOS for R, you may wish to check out:

http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/

Sincerely,

JJB

On 10/14/17, 10:01 AM, "R-SIG-Mac on behalf of Marc Girondot via R-SIG-Mac" <r-sig-mac-bounces at r-project.org on behalf of r-sig-mac at r-project.org> wrote:

    I would be most interested to get a solution for my problem in rJava 
    install.
    
    R 3.4.2
    
    MacOSx 10.12.6, Sierra
    
    Xcode 9.
    
    If I install the rJava package, I get this error:
    
    #######
    
     > install.packages("rJava")
    essai de l'URL 'https://cran.r-project.org/src/contrib/rJava_0.9-9.tar.gz'
    Content type 'application/x-gzip' length 660454 bytes (644 KB)
    ==================================================
    downloaded 644 KB
    
    * installing *source* package ‘rJava’ ...
    
    ####### many lines
    
    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’
    
    #######
    
    clang does not understand the option -fopenmp
    
    This version of clang comes with xCode 9:
    Apple LLVM version 9.0.0 (clang-900.0.37)
    Target: x86_64-apple-darwin16.7.0
    Thread model: posix
    InstalledDir: 
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    
    Then I install clang 5.0.0
    
    clang version 5.0.0 (tags/RELEASE_500/final)
    Target: x86_64-apple-darwin16.7.0
    Thread model: posix
    InstalledDir: /usr/local/opt/llvm/bin
    
    This time, the error is:
    
    #######
    
    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)
    
    #######
    
    Has someone a solution to compile rJava ?
    
    Thanks
    
    Marc
    
    _______________________________________________
    R-SIG-Mac mailing list
    R-SIG-Mac at r-project.org
    https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list