歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubntu 14.04 LTS 下編譯安裝R Source Code

Ubntu 14.04 LTS 下編譯安裝R Source Code

日期:2017/2/28 14:02:57   编辑:Linux教程

有圖有真相,先看圖:

在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)
配置相關的知識可以看這裡 http://www.linuxidc.com/Linux/2015-04/115791.htm

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.linuxidc.com/

用戶名與密碼都是www.linuxidc.com

具體下載目錄在 /2015年資料/4月/4日/Ubntu 14.04 LTS 下編譯安裝R Source Code/

下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm

------------------------------------------分割線------------------------------------------

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 http://www.linuxidc.com/Linux/2014-10/108402.htm

Ubuntu 14.10 正式發布下載 http://www.linuxidc.com/Linux/2014-10/108363.htm

Ubuntu 14.04 LTS 如何升級到 Ubuntu 14.10 http://www.linuxidc.com/Linux/2014-10/108381.htm

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved