楼主: ariera
11198 12

[学习分享] Ubntu 14.04 LTS 下编译安装R Source Code [推广有奖]

  • 0关注
  • 18粉丝

已卖:519份资源

副教授

36%

还不是VIP/贵宾

-

威望
0
论坛币
7871 个
通用积分
48.2642
学术水平
25 点
热心指数
29 点
信用等级
18 点
经验
54323 点
帖子
216
精华
1
在线时间
1269 小时
注册时间
2010-5-24
最后登录
2023-3-2

楼主
ariera 学生认证  发表于 2014-10-16 13:10:41 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
在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.1.1了,它居然还停留在3.0.2,这强迫症,不能忍,而且好多包需要最新版才可以.
于是乎....打开最近的镜像下载源码..
这个是 R-3.1.1 的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 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..提示没有找到软件包,
  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
复制代码
一切顺利!!!!最后给出的判定:
  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


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Source code ODE COD bnt ubuntu 编译

已有 2 人评分论坛币 学术水平 收起 理由
dxystata + 20 + 1 谢谢分享!
求证1加1 + 20 + 1 根据规定进行奖励

总评分: 论坛币 + 40  学术水平 + 2   查看全部评分

本帖被以下文库推荐

  • · R学习|主题: 262, 订阅: 161

沙发
gssdzc 在职认证  发表于 2014-10-16 21:24:02
非常感谢分享。。。。。

藤椅
neversarah 发表于 2014-10-17 13:14:44
感谢分享 非常有用~

板凳
陈宝林 发表于 2014-10-17 17:06:18
貌似真正编译的时候问题不只这些的,比如要安装Rstudio,画图什么的,还需要其他步骤

报纸
627161116 发表于 2014-10-18 10:11:08 来自手机
谢谢分享!

地板
ariera 学生认证  发表于 2014-10-19 08:21:06
陈宝林 发表于 2014-10-17 17:06
貌似真正编译的时候问题不只这些的,比如要安装Rstudio,画图什么的,还需要其他步骤
你应该先去看看 什么是R,什么是Rstudio,我就不给你介绍了。画图什么的是R的功能,不是Rstudio的,不鄙视那些用Rstudio的,但萝卜白菜各有所爱,我也不喜欢R的界面,更习惯于eclpse。

7
陈宝林 发表于 2014-10-20 18:31:26
ariera 发表于 2014-10-19 08:21
你应该先去看看 什么是R,什么是Rstudio,我就不给你介绍了。画图什么的是R的功能,不是Rstudio的,不鄙视 ...
你这人说话感觉语气这么怪,看来你是没有安装过Rstudio的,中途会出错的,至于您的Eclipse,你牛逼,不跟你讨论了;而且我好像没说画图是Rstudio的功能,只是在Rstudio中有时画不了图的,你没遇到过的话就不要乱喷了

8
ariera 学生认证  发表于 2014-10-21 15:27:55
陈宝林 发表于 2014-10-20 18:31
你这人说话感觉语气这么怪,看来你是没有安装过Rstudio的,中途会出错的,至于您的Eclipse,你牛逼,不跟 ...
sorry, 可能语气重了些。有人给我推荐过 Rstudio ,试了一下,感觉不习惯。才疏学浅,请勿见怪

9
曲散人终 发表于 2015-1-14 11:34:04
他丫的。。。我按照楼主的方法在./configure有一个警告。。。什么无法获得pdf的帮助什么的,但是make的时候直接是conftest.c:1:17: 致命错误:jni.h:没有那个文件或目录...敢问楼主知道这个是什么原因吗?我去查了一下好像是没有jni.h这个头文件。。。但是我用yum install java更新了之后依然提示这个错误。。。望指教。。。

10
曲散人终 发表于 2015-1-14 11:55:16
我也不知道怎么的就解决了。。。我把另一个机器的jni.h和jni_md.h(好像是这个名字)复制到我的机器。。。结果就莫名其妙地装好了。。。还是谢谢楼主。。。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 13:41