R:rJava无法安装在Mac OSX 10.8.5';lzma库丢失';和';libjri.jnilib make error';

R:rJava无法安装在Mac OSX 10.8.5';lzma库丢失';和';libjri.jnilib make error';,java,r,macos,rjava,Java,R,Macos,Rjava,使用install.packages(“rJava”)安装rJava时,我会遇到几个错误 lm-mb:~ lisa$ R R Under development (unstable) (2013-11-21 r64282) -- "Unsuffered Consequences" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin10.8.0 (64-bit)

使用
install.packages(“rJava”)
安装rJava时,我会遇到几个错误

lm-mb:~ lisa$ R

R Under development (unstable) (2013-11-21 r64282) -- "Unsuffered Consequences"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("rJava")
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://www.stats.bris.ac.uk/R/src/contrib/rJava_0.9-4.tar.gz'
Content type 'application/x-gzip' length 498108 bytes (486 Kb)
opened URL
==================================================
downloaded 486 Kb

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... llvm-gcc-4.2 -arch x86_64 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether llvm-gcc-4.2 -arch x86_64 -std=gnu99 accepts -g... yes
checking for llvm-gcc-4.2 -arch x86_64 -std=gnu99 option to accept ISO C89... none     needed
checking how to run the C preprocessor... llvm-gcc-4.2 -arch x86_64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether llvm-gcc-4.2 -arch x86_64 -std=gnu99 supports static     inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
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/System/Library/Frameworks/JavaVM.framework/Headers'
java libs   : '-framework JavaVM'
checking whether JNI programs can be compiled... yes
checking JNI data types... ok
checking whether JRI should be compiled (autodetect)... yes
checking whether debugging output should be enabled... no
checking whether memory profiling is desired... no
checking whether threads support is requested... no
checking whether callbacks support is requested... no
checking whether JNI cache support is requested... no
checking whether JRI is requested... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
config.status: creating src/config.h
=== configuring in jri     (/private/var/folders/dn/lvhnwvq15n37bdh0dqm033zh0000gp/T/RtmpuD563L/R.INSTALL158732c239a6c/rJava/jri)
configure: running /bin/sh ./configure '--prefix=/usr/local'  --cache-file=/dev/null --    srcdir=.
checking build system type... i386-apple-darwin12.5.0
checking host system type... i386-apple-darwin12.5.0
checking for gcc... llvm-gcc-4.2 -arch x86_64 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether llvm-gcc-4.2 -arch x86_64 -std=gnu99 accepts -g... yes
checking for llvm-gcc-4.2 -arch x86_64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... llvm-gcc-4.2 -arch x86_64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking whether Java interpreter works... checking whether JNI programs can be     compiled... yes
checking whether JNI programs can be run... yes
checking JNI data types... ok
checking whether Rinterface.h exports R_CStackXXX variables... yes
checking whether Rinterface.h exports R_SignalHandlers... yes
configure: creating ./config.status
config.status: creating src/Makefile
config.status: creating Makefile
config.status: creating run
config.status: creating src/config.h
** libs
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c Rglue.c -o Rglue.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c arrayc.c -o arrayc.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c callJNI.c -o callJNI.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c callback.c -o callback.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c fields.c -o fields.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c init.c -o init.o
init.c: In function ‘initJVM’:
init.c:100: warning: ‘JNI_GetDefaultJavaVMInitArgs’ is deprecated (declared at     /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1934)
init.c:139: warning: ‘JNI_CreateJavaVM’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1937)
init.c: In function ‘RinitJVM’:
init.c:278: warning: ‘JNI_GetCreatedJavaVMs’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1940)
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c jri_glue.c -o jri_glue.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c loader.c -o loader.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c otables.c -o otables.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c rJava.c -o rJava.o
rJava.c: In function ‘getJNIEnv’:
rJava.c:200: warning: ‘JNI_GetCreatedJavaVMs’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1940)
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I. -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/include    -fPIC  -mtune=core2 -g -O2  -c tools.c -o tools.o
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o rJava.so Rglue.o arrayc.o callJNI.o callback.o fields.o init.o jri_glue.o loader.o otables.o rJava.o tools.o -framework JavaVM -F/Library/Frameworks/R.framework/.. -    framework R -Wl,-framework -Wl,CoreFoundation
(cd ../jri && make)
make -C src JRI.jar
/usr/bin/javac -target 1.4 -source 1.4 -d . ../Mutex.java ../RBool.java             ../RConsoleOutputStream.java ../REXP.java ../RFactor.java ../RList.java     ../RMainLoopCallbacks.java ../RVector.java ../Rengine.java ../package-info.java
/usr/bin/javah -d . -classpath . org.rosuda.JRI.Rengine
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o Rengine.o Rengine.c -g -Iinclude  -    DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2  -    I/System/Library/Frameworks/JavaVM.framework/Headers  -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o jri.o jri.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2  -I/System/Library/Frameworks/JavaVM.framework/Headers  -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o Rcallbacks.o Rcallbacks.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2  -I/System/Library/Frameworks/JavaVM.framework/Headers  -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
Rcallbacks.c: In function ‘checkEnvironment’:
Rcallbacks.c:46: warning: ‘JNI_GetCreatedJavaVMs’ is deprecated (declared at /System/Library/Frameworks/JavaVM.framework/Headers/jni.h:1940)
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o Rinit.o Rinit.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2  -I/System/Library/Frameworks/JavaVM.framework/Headers  -fno-common -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o globals.o globals.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2  -I/System/Library/Frameworks/JavaVM.framework/Headers  -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -c -o rjava.o rjava.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -mtune=core2 -g -O2  -I/System/Library/Frameworks/JavaVM.framework/Headers  -fno-common -I/System/Library/Frameworks/JavaVM.framework/Headers
llvm-gcc-4.2 -arch x86_64 -std=gnu99 -o libjri.jnilib Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o  -dynamiclib -framework JavaVM -F/Library/Frameworks/R.framework/.. -framework R -llzma -licucore -lm -liconv
ld: library not found for -llzma
collect2: ld returned 1 exit status
make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rJava’

The downloaded source packages are in
    ‘/private/var/folders/dn/lvhnwvq15n37bdh0dqm033zh0000gp/T/Rtmp5B1vEJ/downloaded_packages’
Warning message:
In install.packages("rJava") :
  installation of package ‘rJava’ had non-zero exit status
第一个报告我缺少与
lzma
关联的库。通过谷歌搜索,我知道这个库,
liblzma
,与XY文件压缩有关吗?这是正确的吗?如果是,我在哪里可以获得这个库

我不知道为什么在尝试构建时会出现其他错误?我猜它们与我的Java环境有关

make[2]: *** [libjri.jnilib] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
我已经更新了Java版本,现在正在运行最新版本

lm-mb:~ lisa$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
我还看到了
libjdns\u sd.jnilib

lm-mb:jre lisa$ ls /usr/lib/java/
libjdns_sd.jnilib
我还根据这篇文章设置了我的
JAVA\u主页
环境

非常感谢您的帮助。

对于linux用户(在14.04上测试):

我也有类似的问题,但在我的环境中,我使用Java1.6。我通过安装丢失的lzma库解决了这个问题

sudo apt-get install liblzma-dev

希望它能帮助某人:)干杯

我遇到了同样的问题,我似乎通过安装mac二进制版本解决了这个问题,如下所示:

install.packages("rJava", type="mac.binary")
如果您确实需要使用lzma库,您可能会幸运地通过MacPorts安装它:

sudo port install lzma

我使用的是OS X 10.6.8(Snow Leopard)。

一种方法:安装自制软件,然后安装xz。你试过R CMD javareconf吗?这是关于MacOS的,我怀疑他们是否有
apt获得那里的
。我将在这里为2015年10月添加一条评论,因为这对我也有效。我无法安装依赖于rJava的一系列软件包,但通过使用
sudo
在命令行中工作,我可以安装所有软件包。
sudo port install lzma