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:

      apt-get install texlive
...我呵呵了,上次装texlive 不能编译中文的问题把我搞得半死,,,但是还是要安啊 至少可以编译英文....
安装完texlive,然后重新执行
./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib
提示如下:
configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally
懂一点latex 的应该能看出来,是latex  inconsolata.sty 和 zi4.sty 包
应该是安装一个就可以的,试了一下果然如此.
在CTAN搜索 inconsolata ,找到了inconsolata 包的下载地址

------------------------------------------分割线------------------------------------------

免费下载地址在 http://linux.bkjia.com/

用户名与密码都是www.bkjia.com

具体下载目录在 /2015年资料/4月/4日/Ubntu 14.04 LTS 下编译安装R Source Code/

下载方法见

------------------------------------------分割线------------------------------------------

texlive 默认安装位置后sty 存放的位置为:/usr/share/texlive/texmf-dist/tex/latex
将上述下载的压缩包整个文件夹解压到 上述目录,需要sudo权限才能移动到该目录,如果命令用的不好,可以执行
sudo nautilus
在弹出的文件管理器中打开该压缩包拖进该弹出的文件管理器的上述目录下.
然后刷新一下 sty 就好.
sudo mktexlsr
或者
sudo texhash
然后此时执行
./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib
一切顺利!!!!最后给出的判定:
R is now configured for i686-pc-linux-gnu

 

  Source directory:          .

  Installation directory:    /home/pc/program/R-3.1.1

 

  C compiler:                gcc -std=gnu99  -g -O2

  Fortran 77 compiler:      gfortran  -g -O2

 

  C++ compiler:              g++  -g -O2

  C++ 11 compiler:          g++  -std=c++11 -g -O2

  Fortran 90/95 compiler:    gfortran -g -O2

  Obj-C compiler:             

 

Interfaces supported:     

External libraries:       

Additional capabilities:  PNG, JPEG, NLS

Options enabled:          shared R library, shared BLAS, R profiling

Recommended packages:      yes

2.编译
make
然后等着...这个有点久...
3.安装
make install

注:以上命令执行时大部分需要在R源码文件夹目录下执行.当然如果工作目录一直保持在源码目录,也是可以的.
最终修成正果。

U盘安装Ubuntu 14.10

Ubuntu 14.10 正式发布下载

Ubuntu 14.04 LTS 如何升级到 Ubuntu 14.10 

相关内容