【编译R语言】
1、下载安装R语言
# 下载R-3.3.2 $ wget https://cran.r-project.org/src/base/R-3/R-3.3.2.tar.gz # 安装R-3.3.2 $ tar -zxvf R-3.3.2.tar.gz $ cd R-3.3.2 # 安装到默认目录下 --perfix=/opt/R 或 /usr/local/lib64/R $ ./configure --prefix=/opt/R --with-readline=yes --with-x=yes --enable-R-shlib $ make $ make install # 配置R环境变量 $ vim /etc/profile export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/R/lib64/R/lib/ #或 /usr/local/lib64/R/lib64/R/lib export PATH=/opt/R/lib64/R/bin:$PATH # (保存修改:Esc --> Shift+: --> wq)
2、测试R语言是否编译成功
R R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos,'help()' for on-line help,or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. q()
Error1:--with-readline=yes (default) and headers/libs are not available
$ yum install readline-devel
Error2:–with-x=yes (default) and X11 headers/libs are not available
$ yum install libXt-devel
Error3: make 过程中会出现类似错误:checking if XXX version >= 1.0.6... no,可以参考:
# step1:下载安装zlib $ wget http://www.zlib.net/zlib-1.2.11.tar.gz $ tar zlib-1.2.11.tar.gz $ cd zlib-1.2.11.tar.gz $ ./configure --prefix=/opt/packages $ make $ make install # step2:下载和安装bzip2: # bzip2不是标准的GNU包,根据下载的安装文件的说明文档,执行以下命令: $ 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 $ make -f Makefile-libbz2_so $ make clean $ make $ make install PREFIX=/opt/packages # 注意:这里下载完bzip2后,需要修改Makefile文件,在CFLAGS这个变量后面添加:-fPIC,否则后面安装R的时候会报错。 # step3:安装xz包: $ wget http://tukaani.org/xz/xz-5.2.2.tar.gz $ tar xzvf xz-5.2.2.tar.gz $ cd xz-5.2.2 $ ./configure --prefix=/opt/packages $ make -j3 $ make install # step4:安装pcre包: $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz $ tar xzvf pcre-8.38.tar.gz $ cd pcre-8.38 $ ./configure --enable-utf8 --prefix=/opt/packages $ make -j3 $ make install # step5:安装curl包: $ wget --no-check-certificate http://curl.haxx.se/download/curl-7.51.0.tar.gz $ tar -zxf curl-7.51.0.tar.gz $ cd curl-7.51.0 $ ./configure --prefix=/opt/packages $ make -j3 $ make install # step6:设置安装好的包的环境变量(!这步最重要): export PATH=/opt/packages/bin:PATH export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/opt/packages/lib/ export CFLAGS="-I/opt/packages/include" export LDFLAGS="-L/opt/packages/lib" # 前两个是安装R的“make”过程需要用到的,后两个是“configure”过程需要用到的。
Error4: /opt/packages/lib/libbz2.a: could not read symbols: Bad value
参考网站:
# step1:删除原先安装的库(这三个东西一环扣一环,真麻烦) # 如果发现 libbz2.a: could not read symbols: Bad value # 就应该把/opt/packages/lib中的libbz2.a删掉 # 进入解压缩的zlib-1.2.8目录,用make clean命令清理一下。 # 同样,/opt/packages/libz.a: could not read symbols # 操作同上,删掉libz.a,把bzip2-1.0.4目录的编译文件清理一下。 # step2:修改zlib-1.2.8的Makefile文件 # 把gcc的编译参数加上 -fPIC $ cd zlib-1.2.8 $ vi Makefile # 原文:CFLAGS=-O3 -DUSE_MMAP # 修改为:CFLAGS=-O3 -DUSE_MMAP -fPIC # (保存修改:Esc --> Shift+: --> wq) make clean #清理之前的编译,再按错误三的方法安装 # step3:修改bzip2-1.0.6的Makefile文件 $ cd bzip2-1.0.6 $ vi Makefile #按下面改 # CC=gcc -fPIC # AR=ar # RANLIB=ranlib # LDFLAGS= # BIGFILES=-D_FILE_OFFSET_BITS=64 # CFLAGS=-fPIC -Wall -Winline -O2 -g (BIGFILES) # (保存修改:Esc --> Shift+: --> wq) $ make clean #清理之前的编译,再按错误3的方法安装
Error5:
/usr/bin/ld: warning: liblzma.so.5,needed by ../../lib/libR.so,not found (try using -rpath or -rpath-link)
../../lib/libR.so: undefined reference to `lzma_code@XZ_5.0'
../../lib/libR.so: undefined reference to `lzma_raw_encoder@XZ_5.0'
../../lib/libR.so: undefined reference to `lzma_stream_decoder@XZ_5.0'
............................
../../lib/libR.so: undefined reference to `pcre_study'
../../lib/libR.so: undefined reference to `lzma_stream_encoder@XZ_5.0'
collect2: 错误:ld 返回 1
make[3]: * [R.bin] 错误 1
make[3]: Leaving directory `/home/lingang/R-3.3.2/src/main'
make[2]: * [R] 错误 2
make[2]: Leaving directory `/home/lingang/R-3.3.2/src/main'
make[1]: * [R] 错误 1
make[1]: Leaving directory `/home/lingang/R-3.3.2/src'
make: * [R] 错误 1
# 解决方法:加环境变量,上面错误是因为没加环境变量 $ set #看是否有LD_LIBRARY_PATH=/opt/packages/lib/ # 如没有输入如下: $ export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/opt/packages/lib/
Error6:
make: * [install-sources2] 错误 1
# 解决方法: $ vim doc/Makefile # 将18、19行改为下面这样,即去掉NEWS.pdf INSTFILES2 = NEWS.rds NEWSNON_SVN_INSTFILES = FAQ RESOURCES NEWS INSTFILES2 = NEWS.rds NEWS # 19 #NEWS.pdf # 20 NON_SVN_INSTFILES = FAQ RESOURCES NEWS # 21 #NEWS.pdf # 22 ## generated later. # (保存修改:Esc --> Shift+: --> wq)
[编译Rstudio-Server]
不同的系统环境,有对应不同的安装方式与安装包,安装前先确定系统环境
确定系统版本为Cent OS(5.4+)
可以参照:https://www.rstudio.com/produ...
$ cat /etc/issue CentOS release 6.4 (Final)
确认以下动态链接库文件已安装,
libcairo.so.2 libcrypto.so.6 libgfortran.so.1 libpango-1.0.so.0 libpangocairo-1.0.so.0 libssl.so.6 openssl098e-0.9.8e
否则可以按如下方式安装:
$ yum install libcrypto.so.6 $ yum install libgfortran.so.1 $ yum install openssl098e-0.9.8e $ yum install libcairo.so.2 $ yum install libpango-1.0.so.0 $ yum install libpangocairo-1.0.so.0 $ yum install libssl.so.6
安装rstudio server并验证:
# 安装rstudio server $ wget https://download2.rstudio.org/rstudio-server-rhel-1.0.44-x86_64.rpm $ rpm -Uvh --nodeps rstudio-server-rhel-1.0.44-x86_64.rpm # 验证是否成功 $ rstudio-server verify-installation rstudio-server stop/waiting rstudio-server start/running # 如果在验证安装是否正确时,仍然会报某些动态链接库文件,无法找到如: # 可能会报libgfortran.so.1无法找到,但/usr/lib64目录下有更高版本的 # libgfortran.so.3.0.0时,可以下命令来解决: $ ln –s /usr/lib64/ libgfortran.so.3.0.0 /usr/lib64/ libgfortran.so.1 # 配置Rstudio-server端口 $ vi /etc/rstudio/rserver.conf www-port=8787 rsession-which-r=/opt/R/lib64/R/bin/R #(保存修改:Esc --> Shift+: --> wq)
# 创建账户 $ usradd test # 创建账户密码 $ passwd test
用户创建成功后访问:http://XXX.XX.XXX.XX:8787/,登陆以上账号,即可使用Rstudio-server。
Error1:Error: Cannot retrieve Metalink for repository: epel. Please verify its path and try again
$ yum -y install epel-release $ vi /etc/yum.repos.d/epel.repo #<把 #name baseurl 改为 name #baseurl> 例如: # #name=Extra Packages for Enterprise Linux 6 - basearch # baseurl=http://download.fedoraproject.org/pub/epel/6/basearch # 改为: # name=Extra Packages for Enterprise Linux 6 - basearch # #baseurl=http://download.fedoraproject.org/pub/epel/6/basearch # (保存修改:Esc --> Shift+: --> wq)