Ubntu 14.04 LTS 下编译安装R Source Code

5 篇文章 0 订阅
在Ubuntu 14.04 LTS 发布后,立刻重装.
作为一名伪统计学爱好者,不得不装R软件...
于是ctrl +alt+T 打开终端,输入 
  1. sudo apt-get install R-base-core
复制代码
....然后习惯性地...输入
  1. R
复制代码

...我去,我惊讶了
  1. R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
  2. Copyright (C) 2013 The R Foundation for Statistical Computing
  3. Platform: i686-pc-linux-gnu (32-bit)
复制代码
R官网都更新到3.2.2了,它居然还停留在3.2.2,这强迫症,不能忍,而且好多包需要最新版才可以.
于是乎....打开 最近的镜像 下载源码..
这个是  3.2.2 的source code.下载后解压....解压命令自行百度或嘿嘿...拖拽也成
然后下面是编译安装的过程. 
源码的安装一般由3个步骤组成:配置(configure)、编译(make)、安装(make install)
配置相关的知识可以看 这里
1.配置
cd 切到源码文件夹下,输入
  1. ./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib
复制代码

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

原因是没有安装gfortran,可以执行
  1. sudo apt-get install gfortran
复制代码

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


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

  1. configure: WARNING: you cannot build DVI versions of the R manuals
  2. configure: WARNING: you cannot build DVI versions of all the help pages
  3. configure: WARNING: you cannot build info or HTML versions of the R manuals
  4. configure: WARNING: you cannot build PDF versions of the R manuals
  5. 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 have makeinfo  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, especially texinfo.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..提示没有找到软件包,
  1. sudo apt-get install texinfo
复制代码

有这个软件包名,安装结束终端输入
  1. makeinfo --help
复制代码

才发现,texinfo中包含了makeinfo,到此你可能认为这样可以了,终于可以编译生成文档了,或许你可以,当然我重装系统前也可以....
再次执行
  1. ./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib
复制代码
提示:
  1. configure: WARNING: you cannot build PDF versions of the R manuals
  2. configure: WARNING: you cannot build PDF versions of vignettes and help pages
复制代码
且不表我的心情,假装我当时很从容.
再次翻看那部分英文说明,确实没错啊,编译 pdf 需要texi2dvi,但是texi2dvi是在texinfo中的,
然后我怏怏地执行了一下
  1. texi2dvi --help
复制代码
提示是这么说的:
  1. You don't have a working TeX binary installed, but the texi2dvi script
  2. can't proceed without it. If you want to use this script, you have to
  3. install some kind of TeX, for example TeX Live Debian packages. You can do
  4. that with this command:
  5.        apt-get install texlive
复制代码
...我呵呵了,上次装texlive 不能编译中文的问题把我搞得半死,,,但是还是要安啊 至少可以编译英文....
安装完texlive,然后重新执行
  1. ./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib
复制代码
提示如下:
  1. 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 包的下载地址
texlive 默认安装位置后sty 存放的位置为:/usr/share/texlive/texmf-dist/tex/latex
将上述下载的压缩包整个文件夹解压到 上述目录,需要sudo权限才能移动到该目录,如果命令用的不好,可以执行
  1. sudo nautilus
复制代码
在弹出的文件管理器中打开该压缩包拖进该弹出的文件管理器的上述目录下.
然后刷新一下 sty 就好.
  1. sudo mktexlsr
复制代码
或者
  1. sudo texhash
复制代码
然后此时执行
  1. ./configure --prefix=/home/pc/program/R-3.1.1 --enable-R-shlib
  2. wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
    tar xzvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6
  3. 修改bzip2-1.0.6的Makefile文件 
    CC=gcc -fPIC
  4. make clean
  5. make -f Makefile-libbz2_so
    make
    make install

  6.  sudo apt-get isntall liblzma-dev

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
tar xzvf pcre-8.38.tar.gz
./configure --enable-utf8 
make 
make install

wget --no-check-certificate https://curl.haxx.se/download/curl-7.47.1.tar.gz
tar xzvf curl-7.47.1.tar.gz
cd curl-7.47.1
 ./configure
 make
 make install

  1. sudo apt-get install libpng-dev
  2. sudo apt-get install libreadline6-dev
     ./configure --enable-R-shlib --with-libpng


复制代码
一切顺利!!!!最后给出的判定:
  1. R is now configured for i686-pc-linux-gnu

  2.   Source directory:          .
  3.   Installation directory:    /home/pc/program/R-3.1.1

  4.   C compiler:                gcc -std=gnu99  -g -O2
  5.   Fortran 77 compiler:       gfortran  -g -O2

  6.   C++ compiler:              g++  -g -O2
  7.   C++ 11 compiler:           g++  -std=c++11 -g -O2
  8.   Fortran 90/95 compiler:    gfortran -g -O2
  9.   Obj-C compiler:              

  10.   Interfaces supported:      
  11.   External libraries:        
  12.   Additional capabilities:   PNG, JPEG, NLS
  13.   Options enabled:           shared R library, shared BLAS, R profiling

  14.   Recommended packages:      yes
复制代码

2.编译
  1. make
复制代码
然后等着...这个有点久...
3.安装
  1. make install
复制代码

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


2014-10-16 14:38:05 的屏幕截图2.png 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值