安装rJava时,安装成功完成,但进程中存在大量警告。这是第一个:
jri_glue.c: In function ‘PushToREXP’:
jri_glue.c:24:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
jpar[1].j = (jlong) robj;
^
jri_glue.c: In function ‘RReleaseREXP’:
jri_glue.c:52:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
SEXP x = (SEXP) r;
^
这是第二个警告:
warning: [options] bootstrap class path not set in conjunction with -source 1.4
warning: [options] source value 1.4 is obsolete and will be removed in a future release
warning: [options] target value 1.4 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
4 warnings
以下是第三组警告的第一行,总共包含近500行:
In file included from Rengine.c:4:0:
Rengine.c: In function ‘Java_org_rosuda_JRI_Rengine_rniParse’:
jri.h:21:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define SEXP2L(s) ((jlong)(s))
^
Rengine.c:121:14: note: in expansion of macro ‘SEXP2L’
return SEXP2L(pstr);
^
我认为存在问题的原因如下:当我尝试安装另一个依赖于rJava
的软件包,即XLConnectJars
时,我遇到了分段错误:
> install.packages("XLConnectJars")
[...]
* installing *source* package ‘XLConnectJars’ ...
** Paket ‘XLConnectJars’ erfolgreich entpackt und MD5 Summen überprüft
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Segmentation fault (core dumped)
ERROR: loading failed
为什么会发生这种情况,我该怎么办呢?
2017年6月/ 7月,在更新内核4.4.0-81-generic
后出现类似问题,但内核已被修补:
https://github.com/miraisolutions/xlconnect/issues/70
(我当前的内核是4.10.0-35-generic
。)
此外,在那里和相关线程中建议的变通方法(比如使用-Xss2048k
选项增加线程堆栈大小)在我的机器上不起作用。
按照许多地方的建议通过rJava
安装sudo apt-get install r-cran-rjava
也无济于事。
我的java版本是
~$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK Server VM (build 25.131-b11, mixed mode)
和sessionInfo()返回
R version 3.4.2 (2017-09-28)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu 16.04.3 LTS
Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
locale:
[1] LC_CTYPE=de_DE.UTF-8 LC_NUMERIC=C LC_TIME=de_DE.UTF-8
[4] LC_COLLATE=de_DE.UTF-8 LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=de_DE.UTF-8
[7] LC_PAPER=de_DE.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rJava_0.9-8
loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2
感谢您的帮助。