步驟一: 安裝必要的套件如liblzma5
$ sudo apt-get install liblzma5 liblzma-dev
若沒有安裝,會出現下面的錯誤訊息configure: error: "liblzma library and headers are required"
步驟二:下載R-3.5.1原始碼
$ wget https://cran.rstudio.com/src/base/R-3/R-3.5.1.tar.gz
$ md5sum R-3.5.1.tar.gz
8620686bc237cf80288afff336fcc93c R-3.5.1.tar.gz
步驟三:指定安裝資料夾/opt/R/3.5.1,開始編譯
$ tar zxf R-3.5.1.tar.gz && cd R-3.5.1/
$ ./configure --prefix=/opt/R/3.5.1 --with-x=no
...
$ make
...
R is now configured for x86_64-pc-linux-gnu
Source directory: .
Installation directory: /opt/R/3.5.1
C compiler: gcc -std=gnu99 -g -O2
Fortran 77 compiler: gfortran -g -O2
Default C++ compiler: g++ -g -O2
C++98 compiler: g++ -std=gnu++98 -g -O2
C++11 compiler: g++ -std=gnu++11 -g -O2
C++14 compiler:
C++17 compiler:
Fortran 90/95 compiler: gfortran -g -O2
Obj-C compiler:
Interfaces supported:
External libraries: readline, curl
Additional capabilities: PNG, JPEG, NLS, ICU
Options enabled: shared BLAS, R profiling
Capabilities skipped: TIFF, cairo
Options not enabled: memory profiling
Recommended packages: yes
這個步驟要是出現缺什麼函式庫的,回到步驟一用apt-get去安裝步驟四:檢查編譯的是否正確,看執行檔
$ make check
...
$ ldd bin/exec/R
linux-vdso.so.1 => (0x00007ffe3a1b4000)
libRblas.so => not found
libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007fa09350f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa09328d000)
libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007fa093058000)
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fa092e11000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fa092bd4000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fa0929b1000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007fa0927a1000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa09258a000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa092382000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa09217e000)
libicuuc.so.48 => /usr/lib/x86_64-linux-gnu/libicuuc.so.48 (0x00007fa091e0f000)
libicui18n.so.48 => /usr/lib/x86_64-linux-gnu/libicui18n.so.48 (0x00007fa091a44000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007fa091836000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa09161a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa09128d000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa093825000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa091077000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fa090e4e000)
libicudata.so.48 => /usr/lib/x86_64-linux-gnu/libicudata.so.48 (0x00007fa08fade000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa08f7d7000)
步驟五:安裝到指定資料夾
$ sudo make install
...
$ tree -L 2 /opt/R/3.5.1
/opt/R/3.5.1
|-- bin
| |-- R
| `-- Rscript
|-- lib
| `-- R
`-- share
`-- man
$ du -h --max-depth=3 /opt/R/3.5.1/
16K /opt/R/3.5.1/share/man/man1
20K /opt/R/3.5.1/share/man
24K /opt/R/3.5.1/share
472K /opt/R/3.5.1/lib/R/include
28K /opt/R/3.5.1/lib/R/etc
776K /opt/R/3.5.1/lib/R/share
5.8M /opt/R/3.5.1/lib/R/lib
636K /opt/R/3.5.1/lib/R/modules
3.3M /opt/R/3.5.1/lib/R/doc
62M /opt/R/3.5.1/lib/R/library
14M /opt/R/3.5.1/lib/R/bin
86M /opt/R/3.5.1/lib/R
86M /opt/R/3.5.1/lib
44K /opt/R/3.5.1/bin
86M /opt/R/3.5.1/
安裝完的/opt/R/3.5.1有86MB步驟六:執行剛剛安裝好的R-3.5.1
$ /opt/R/3.5.1/bin/R
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 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.
During startup - Warning message:
Setting LC_CTYPE failed, using "C"
> q()
Save workspace image? [y/n/c]: n
沒有留言:
張貼留言