Programing/R- programming

R - rJava 설치 에러날 때

sosal 2015. 12. 19. 22:31
반응형

 

/*

 http://sosal.kr/
 * made by so_Sal
 */

 

특정 R 패키지를 설치하는데, rJava dependency 때문에 설치가 불가능했다.

ERROR: configuration failed for package ‘rJava’
* removing ‘/storage/home/sosal/programs/R/R-devel/library/rJava’

그래서 rJava를 설치하려고 했지만..


> install.packages("rJava")
--- Please select a CRAN mirror for use in this session ---
CRAN mirror

 

<중략>

ERROR: configuration failed for package ‘rJava’
* removing ‘/storage/home/sosal/programs/R/R-devel/library/rJava’

The downloaded source packages are in
        ‘/tmp/RtmpjxCAWz/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rJava") :
  installation of package ‘rJava’ had non-zero exit status

 

 

이렇게 에러가 나면서 rJava 설치에 실패했다.

 

서버에 root 권한은 없고, 유저단에서 해결방법이 어떤게 있는지 찾아보니

R CMD javareconf 라는 명령어가 있었다.

 

 

다음과 같이 입력하면 된다.

 

[sosal@sosal]$ R CMD javareconf
Java interpreter : /storage/home/sosal/programs/jdk1.8.0_25/jre/bin/java
Java version     : 1.8.0_25
Java home path   : /storage/home/sosal/programs/jdk1.8.0_25
Java compiler    : /storage/home/sosal/programs/jdk1.8.0_25/bin/javac
Java headers gen.: /storage/home/sosal/programs/jdk1.8.0_25/bin/javah
Java archive tool: /storage/home/sosal/programs/jdk1.8.0_25/bin/jar

trying to compile and link a JNI program
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/storage/home/sosal/programs/R/R-devel/include -DNDEBUG -I/storage/home/sosal/programs/jdk1.8.0_25/include -I/storage/home/sosal/programs/jdk1.8.0_25/include/linux -I/usr/local/include    -fpic  -g -O2  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o conftest.so conftest.o -L/storage/home/sosal/programs/jdk1.8.0_25/jre/lib/amd64/server -ljvm


JAVA_HOME        : /storage/home/sosal/programs/jdk1.8.0_25
Java library path: $(JAVA_HOME)/jre/lib/amd64/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
Updating Java configuration in /storage/home/sosal/programs/R/R-develDone.


그리고 나서 다시 R을 실행해서

> install.packages("rJava")
--- Please select a CRAN mirror for use in this session ---
<중략>

* DONE (rJava)

The downloaded source packages are in
        ‘/tmp/Rtmpc3jv8D/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
> library(rJava)
>

잘 된다!

 

 

 

 

Ubuntu에서 안되는 분들 중에, root 권한이 있으신 분은 다음의 명령어를 사용하면 될 것 같다.

 

sudo apt-get install r-cran-rjava