Ubntu 14.04 LTS 下编译安装R Source Code

有图有真相,先看图:

Ubntu 14.04 LTS 下编译安装R Source Code

Ubuntu 14.04 LTS 发布之后,立刻重装了系统。作为一名伪统计学爱好者,不得不装R软件...
于是ctrl +alt+T 打开终端,输入

sudo apt-get install R-base-core

....然后习惯性地...输入

R

...我去,我惊讶了

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: i686-pc-linux-gnu (32-bit)

R官网都更新到3.1.1了,它居然还停留在3.0.2,这强迫症,不能忍,而且好多包需要最新版才可以.
于是乎....打开最近的镜像下载源码..
这个是 R-3.1.1 的source code.下载后解压....解压命令自行百度或嘿嘿...拖拽也成
然后下面是编译安装的过程.
源码的安装一般由3个步骤组成:配置(configure)、编译(make)、安装(make install)
配置相关的知识可以看这里

1.配置
cd 切到源码文件夹下,输入

./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib

其中 /home/pc/program/R-3.1.1 是要安装到的路径.
网上有人说此处会提示
“configure: error: No F77 compiler found”

原因是没有安装gfortran,可以执行
sudo apt-get install gfortran

安装一下.
我的提示是
configure: error: --with-x=yes (default) and X11 headers/libs are not available
然后尝试执行
./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib --with-readline=no --with-x=no
此时不会报错,但是如果就此安装的话,最终可能会有上下键不能识别,不能给出历史命令的问题可以安装以下依赖包
sudo apt-get install libreadline6-dev

sudo apt-get install libxt-dev
然后应该就可以了
./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib


但会有一大堆warning....类似如下:

configure: WARNING: you cannot build DVI versions of the R manuals

configure: WARNING: you cannot build DVI versions of all the help pages

configure: WARNING: you cannot build info or HTML versions of the R manuals

configure: WARNING: you cannot build PDF versions of the R manuals

configure: WARNING: you cannot build PDF versions of all the help pages
这都很简单,不用翻译....原因很简单,就是没有编译工具和编译依赖的软件包呗.
但是具体需要哪些包...这让人很捉急....
于是Google之,查CRAN官网文档,发现在这个位置有这么一个存在,这段话是这么说的:(篇幅所限,只截取最关键部分)

To make these (with ‘fullrefman’ rather than ‘refman’), use
make pdf      to create PDF versionsmake info    to create info files (not ‘refman’ nor ‘fullrefman’).
You will not be able to build any of these unless you havemakeinfo version 4.7 or later installed, and for PDF you must have texi2dvi and texinfo.tex installed (which are partof the GNU texinfo distribution but are, especiallytexinfo.tex, often made part of the TeX package inre-distributions).
The PDF versions can be viewed using any recent PDF viewer: they havehyperlinks that can be followed.  The info files are suitable forreading online with Emacs or the standalone GNU infoprogram.  The PDF versions will be created using the paper size selectedat configuration (default ISO a4): this can be overridden by settingR_PAPERSIZEon the make command line, or setting R_PAPERSIZE in theenvironment and using make -e.  (If re-making the manuals fora different paper size, you should first delete the filedoc/manual/version.texi.  The usual value for North America wouldbe ‘letter’.)

那么,我们再来看一下这个makeinfo,textinfo 和 texinfo.tex,
sudo apt-get install makeinfo..提示没有找到软件包,
sudo apt-get install texinfo

有这个软件包名,安装结束终端输入
makeinfo --help

才发现,texinfo中包含了makeinfo,到此你可能认为这样可以了,终于可以编译生成文档了,或许你可以,当然我重装系统前也可以....
再次执行
./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib
提示:
configure: WARNING: you cannot build PDF versions of the R manuals

configure: WARNING: you cannot build PDF versions of vignettes and help pages
且不表我的心情,假装我当时很从容.
再次翻看那部分英文说明,确实没错啊,编译 pdf 需要texi2dvi,但是texi2dvi是在texinfo中的,
然后我怏怏地执行了一下
texi2dvi --help
提示是这么说的:
You don't have a working TeX binary installed, but the texi2dvi script

can't proceed without it. If you want to use this script, you have to

install some kind of TeX, for example TeX Live Debian packages. You can do

that with this command:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/16539.html