Linux 上的 R 包安装

标签 r linux package

我安装了 R 并尝试安装附加包:rgl。问题是,我不断收到此错误:

installation of package ‘rgl’ had non-zero exit status

这是警告的完整列表:

> warnings()
Warning messages:
1: In install.packages("rgl") :
installation of package ‘stringi’ had non-zero exit status
2: In install.packages("rgl") :
installation of package ‘yaml’ had non-zero exit status
3: In install.packages("rgl") :
installation of package ‘digest’ had non-zero exit status
4: In install.packages("rgl") :
installation of package ‘httpuv’ had non-zero exit status
5: In install.packages("rgl") :
installation of package ‘mime’ had non-zero exit status
6: In install.packages("rgl") :
installation of package ‘sourcetools’ had non-zero exit status
7: In install.packages("rgl") :
installation of package ‘jsonlite’ had non-zero exit status
8: In install.packages("rgl") :
installation of package ‘markdown’ had non-zero exit status
9: In install.packages("rgl") :
installation of package ‘stringr’ had non-zero exit status
10: In install.packages("rgl") :
installation of package ‘htmltools’ had non-zero exit status
11: In install.packages("rgl") :
installation of package ‘evaluate’ had non-zero exit status
12: In install.packages("rgl") :
installation of package ‘htmlwidgets’ had non-zero exit status
13: In install.packages("rgl") :
installation of package ‘shiny’ had non-zero exit status
14: In install.packages("rgl") :
installation of package ‘knitr’ had non-zero exit status
15: In install.packages("rgl") :
installation of package ‘rgl’ had non-zero exit status

和完整的安装日志:

> install.packages("rgl")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
also installing the dependencies ‘stringi’, ‘yaml’, ‘digest’, ‘evaluate’, ‘markdown’, ‘stringr’, ‘httpuv’, ‘mime’, ‘sourcetools’, ‘htmlwidgets’, ‘htmltools’, ‘knitr’, ‘jsonlite’, ‘shiny’

trying URL 'https://cloud.r-project.org/src/contrib/stringi_1.1.5.tar.gz'
Content type 'application/x-gzip' length 3645872 bytes (3.5 MB)
==================================================
downloaded 3.5 MB

trying URL 'https://cloud.r-project.org/src/contrib/yaml_2.1.14.tar.gz'
Content type 'application/x-gzip' length 81095 bytes (79 KB)
==================================================
downloaded 79 KB

trying URL 'https://cloud.r-project.org/src/contrib/digest_0.6.12.tar.gz'
Content type 'application/x-gzip' length 120337 bytes (117 KB)
==================================================
downloaded 117 KB

trying URL 'https://cloud.r-project.org/src/contrib/evaluate_0.10.1.tar.gz'
Content type 'application/x-gzip' length 22177 bytes (21 KB)
==================================================
downloaded 21 KB

trying URL 'https://cloud.r-project.org/src/contrib/markdown_0.8.tar.gz'
Content type 'application/x-gzip' length 80583 bytes (78 KB)
==================================================
downloaded 78 KB

trying URL 'https://cloud.r-project.org/src/contrib/stringr_1.2.0.tar.gz'
Content type 'application/x-gzip' length 94095 bytes (91 KB)
==================================================
downloaded 91 KB

trying URL 'https://cloud.r-project.org/src/contrib/httpuv_1.3.5.tar.gz'
Content type 'application/x-gzip' length 427638 bytes (417 KB)
==================================================
downloaded 417 KB

trying URL 'https://cloud.r-project.org/src/contrib/mime_0.5.tar.gz'
Content type 'application/x-gzip' length 12634 bytes (12 KB)
==================================================
downloaded 12 KB

trying URL 'https://cloud.r-project.org/src/contrib/sourcetools_0.1.6.tar.gz'
Content type 'application/x-gzip' length 24092 bytes (23 KB)
==================================================
downloaded 23 KB

trying URL 'https://cloud.r-project.org/src/contrib/htmlwidgets_0.9.tar.gz'
Content type 'application/x-gzip' length 944851 bytes (922 KB)
==================================================
downloaded 922 KB

trying URL 'https://cloud.r-project.org/src/contrib/htmltools_0.3.6.tar.gz'
Content type 'application/x-gzip' length 45408 bytes (44 KB)
==================================================
downloaded 44 KB

trying URL 'https://cloud.r-project.org/src/contrib/knitr_1.17.tar.gz'
Content type 'application/x-gzip' length 769923 bytes (751 KB)
==================================================
downloaded 751 KB

trying URL 'https://cloud.r-project.org/src/contrib/jsonlite_1.5.tar.gz'
Content type 'application/x-gzip' length 1096810 bytes (1.0 MB)
==================================================
downloaded 1.0 MB

trying URL 'https://cloud.r-project.org/src/contrib/shiny_1.0.5.tar.gz'
Content type 'application/x-gzip' length 2330710 bytes (2.2 MB)
==================================================
downloaded 2.2 MB

trying URL 'https://cloud.r-project.org/src/contrib/rgl_0.98.1.tar.gz'
Content type 'application/x-gzip' length 2624282 bytes (2.5 MB)
==================================================
downloaded 2.5 MB

* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
checking for local ICUDT_DIR... icu55/data
checking for R_HOME... /usr/lib/R
checking for R... /usr/lib/R/bin/R
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... no
checking for cat... /bin/cat
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... no
configure: error: in `/tmp/RtmpSv852d/R.INSTALL521c32e70e07/stringi':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘stringi’
* removing ‘/usr/local/lib/R/site-library/stringi’
* installing *source* package ‘yaml’ ...
** package ‘yaml’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -DNDEBUG     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c api.c -o api.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'api.o' failed
make: *** [api.o] Error 1
ERROR: compilation failed for package ‘yaml’
* removing ‘/usr/local/lib/R/site-library/yaml’
* installing *source* package ‘digest’ ...
** package ‘digest’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c aes.c -o aes.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'aes.o' failed
make: *** [aes.o] Error 1
ERROR: compilation failed for package ‘digest’
* removing ‘/usr/local/lib/R/site-library/digest’
* installing *source* package ‘httpuv’ ...
** package ‘httpuv’ successfully unpacked and MD5 sums checked
** libs
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I./libuv/include -I./http-parser -I./sha1 -I./base64 -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I./libuv/include -I./http-parser -I./sha1 -I./base64 -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c filedatasource-unix.cpp -o filedatasource-unix.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I./libuv/include -I./http-parser -I./sha1 -I./base64 -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c filedatasource-win.cpp -o filedatasource-win.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I./libuv/include -I./http-parser -I./sha1 -I./base64 -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c http.cpp -o http.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I./libuv/include -I./http-parser -I./sha1 -I./base64 -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c httpuv.cpp -o httpuv.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I./libuv/include -I./http-parser -I./sha1 -I./base64 -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c md5.c -o md5.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'md5.o' failed
make: *** [md5.o] Error 1
ERROR: compilation failed for package ‘httpuv’
* removing ‘/usr/local/lib/R/site-library/httpuv’
* installing *source* package ‘mime’ ...
** package ‘mime’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c rawmatch.c -o rawmatch.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'rawmatch.o' failed
make: *** [rawmatch.o] Error 1
ERROR: compilation failed for package ‘mime’
* removing ‘/usr/local/lib/R/site-library/mime’
* installing *source* package ‘sourcetools’ ...
** package ‘sourcetools’ successfully unpacked and MD5 sums checked
** libs
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c Reader.cpp -o Reader.o
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c Tokenizer.cpp -o Tokenizer.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I../inst/include     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c sourcetools-init.c -o sourcetools-init.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'sourcetools-init.o' failed
make: *** [sourcetools-init.o] Error 1
ERROR: compilation failed for package ‘sourcetools’
* removing ‘/usr/local/lib/R/site-library/sourcetools’
* installing *source* package ‘jsonlite’ ...
** package ‘jsonlite’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -Iyajl/api     -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c base64.c -o base64.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'base64.o' failed
make: *** [base64.o] Error 1
ERROR: compilation failed for package ‘jsonlite’
* removing ‘/usr/local/lib/R/site-library/jsonlite’
ERROR: dependency ‘mime’ is not available for package ‘markdown’
* removing ‘/usr/local/lib/R/site-library/markdown’
ERROR: dependency ‘stringi’ is not available for package ‘stringr’
* removing ‘/usr/local/lib/R/site-library/stringr’
ERROR: dependency ‘digest’ is not available for package ‘htmltools’
* removing ‘/usr/local/lib/R/site-library/htmltools’
ERROR: dependency ‘stringr’ is not available for package ‘evaluate’
* removing ‘/usr/local/lib/R/site-library/evaluate’
ERROR: dependencies ‘htmltools’, ‘jsonlite’, ‘yaml’ are not available for package ‘htmlwidgets’
* removing ‘/usr/local/lib/R/site-library/htmlwidgets’
ERROR: dependencies ‘httpuv’, ‘mime’, ‘jsonlite’, ‘digest’, ‘htmltools’, ‘sourcetools’ are not available for package ‘shiny’
* removing ‘/usr/local/lib/R/site-library/shiny’
ERROR: dependencies ‘evaluate’, ‘digest’, ‘markdown’, ‘stringr’, ‘yaml’ are not available for package ‘knitr’
* removing ‘/usr/local/lib/R/site-library/knitr’
ERROR: dependencies ‘htmlwidgets’, ‘htmltools’, ‘knitr’, ‘jsonlite’, ‘shiny’ are not available for package ‘rgl’
* removing ‘/usr/local/lib/R/site-library/rgl’

The downloaded source packages are in
    ‘/tmp/Rtmpa3Hizf/downloaded_packages’
There were 15 warnings (use warnings() to see them)

完整的 R 版本信息:

> version
            _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          4.2                         
year           2017                        
month          09                          
day            28                          
svn rev        73368                       
language       R                           
version.string R version 3.4.2 (2017-09-28)
nickname       Short Summer 

我使用 Linux Mint 18.2。我知道还有更多关于该错误消息的问题,但我没有找到任何有效的解决方案。这基本上是全新安装,我没有更改任何配置文件,并尝试在有和没有 root 权限的情况下安装这个包。有谁知道是什么原因造成的?

最佳答案

感谢 r-sig-debian 邮件列表中的 Harutyun Khachatryan,我修复了这个错误。
解决方案在这里:https://askubuntu.com/questions/26498/choose-gcc-and-g-version

唯一的区别是我在 4.8 和 4.9 版本(而不是 4.3 和 4.4)中使用了 gcc 和 g++。

我用来修复它的所有命令:

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo apt-get install gcc-4.3 gcc-4.4 g++-4.3 g++-4.4
sudo apt-get install gcc-4.8 gcc-4.8 g++-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

现在R中的包编译成功。

关于Linux 上的 R 包安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46758330/

相关文章:

r - 将字符向量拆分成句子

linux - Linux 内核中的 realloc() 是否有以下限制?

linux - 用冒号分隔子列表

python - 无法在 Python 中打开 html5lib

r - r 中的向量误差校正模型

r - R 中的 2 色热图,中间色固定到特定值

r - bool 运算中的 dplyr row_number() 行为

c++ - C(++) 套接字 fd_* 正在阻塞/延迟写入/发送

javascript - 如何更改 NPM 版本?

android - 卸载在 Android 中不可见的包