2021-05-12 14:32:11
SUSE Linux Enterprise Server 11 SP3原始碼安裝R過程
SUSE Linux Enterprise Server 11 SP3原始碼編譯安裝R-3.2.2過程詳解。suse上安裝R,過程艱難,文章裡的原始碼包版本都是自己安裝時候所用的版本,不一定必須是該版本。
整體依賴關係:
cairo依賴於X11 , pango依賴於cairo
安裝順序X11 -> cairo -> pango
1.安裝編譯器
先看看R網站的一些說明:
B.6 Using FORTRAN:
.................
To compile R, you need a FORTRAN compiler.
The default is to search for f95, fort, xlf95, ifort,ifc, efc, pgf95 lf95, gfortran, ftn, g95, f90,
xlf90, pghpf, pgf90, epcf90, g77, f77, xlf, frt,pgf77, cf77, fort77, fl32, af77 (in that order)56,
and use whichever is found first; if none is found, Rcannot be compiled. However,
if CC is gcc, the matching FORTRAN compiler (g77 forgcc 3 and gfortran for gcc 4) is used if available
suse預設是沒有gfortran編輯器,所以需要先安裝它
xz -d gcc-trunk.tar.xz
tar -xvf gcc-trunk.tar -C /opt
vi /etc/profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gcc-trunk/lib64:/opt/gcc-trunk/lib
exportLIBRARY_PATH=$LIBRARY_PATH:/opt/gcc-trunk/lib:/opt/gcc-trunk/lib64
export PATH=$PATH:/opt/gcc-trunk/bin
source /etc/profile
which gfortran
/opt/gcc-trunk/bin/gfortran
還需要安裝gcc-c++
zypper in gcc-c++
2.安裝Xorg-X11
安裝cairo需要xlib支援,所有需要X11支援,編譯R需要X11的libX11和libXt
2.1安裝libX11-1.6.5
依賴關係(a,b-> c c依賴於a,b):
(libpthread-stubs-0.3,xcb-proto-1.12,libXau-1.0.4) -> libxcb-1.12
(util-macros-1.19.1,kbproto-1.0.4,xproto-7.0.23,inputproto-2.3.2,xextproto-7.0.3)-> libX11-1.6.5 <- (libxcb-1.12)
1)安裝util-macros-1.19.1
./configure --prefix=/usr/local
make install
2)安裝kbproto-1.0.4
./configure --prefix=/usr/local
make install
3)安裝xproto-7.0.23
./configure --prefix=/usr/local
make
make install
4)安裝inputproto-2.3.2
./configure --prefix=/usr/local
make
make install
5)安裝xextproto-7.0.3
./configure --prefix=/usr/local
make install
6)安裝libpthread-stubs-0.3
./configure --prefix=/usr/local
make
make install
7)安裝xcb-proto-1.12
./configure --prefix=/usr/local
make
make install
8)安裝libXau-1.0.4
./configure --prefix=/usr/local
make
make install
9)安裝libxcb-1.12
./configure --prefix=/usr/local
make
make install
10)安裝libX11-1.6.5
2.2安裝libXt-1.1.5
依賴關係(a,b-> c c依賴於a,b)
(xtrans-1.3.5,libice_1.0.8,libsm_1.2.1) -> libXt-1.1.5
1)安裝xtrans-1.3.5
./configure --prefix=/usr/local
make
make install
2)安裝libICE-1.0.8
./configure --prefix=/usr/local
make
make install
3)安裝libsm_1.2.1
./configure --prefix=/usr/local
make
make install
4)安裝libXt-1.1.5
./configure --prefix=/usr/local
make
make install
3.安裝cairo-1.14.8
R網站的說明:
A.2 Useful libraries and programs:
..............
The ‘modern’ version of the X11(), jpeg(), png() andtiff() graphics devices uses the cairo and (optionally) Pango libraries.
Cairo version 1.2.0 or later is required.
Pango needs to be at least version 1.10, and 1.12 isthe earliest version we have tested.
(For Fedora users we believe the pango-devel RPM andits dependencies suffice.)
R checks for pkg-config, and uses that to check firstthat the ‘pangocairo’ package is installed (and if not, ‘cairo’)
and if additional flags are needed for the‘cairo-xlib’ package,
then if suitable code can be compiled.
These tests will fail if pkg-config is notinstalled48, and are likely to fail if cairo was built statically (unusual).
Most systems with Gtk+ 2.8 or later installed willhave suitable libraries
..............
需要cairo-xlib的支援(需要安裝X11)
依賴關係:(a,b-> c c依賴於a,b)
(libXext-1.0.1,pixman-0.34.0)-> cairo-1.14.8
1)安裝libXext-1.0.1
./configure --prefix=/usr/local
make
make install
2)安裝pixman-0.34.0
./configure --prefix=/usr/local
make
make install
2)安裝cairo-1.14.8
./configure --prefix=/usr/local --disable-static --enable-xlib=yes--enable-ft=yes --enable-xlib-xcb=yes -enable-tee
make
make install
configure的結果:
Thefollowing font backends:
User: yes (always builtin)
FreeType: yes
Fontconfig: yes
Win32: no (requires a Win32 platform)
Quartz: no (requires CoreGraphics framework)
The following functions:
PNGfunctions: yes
GLXfunctions: no (not required by anybackend)
WGLfunctions: no (not required by anybackend)
EGLfunctions: no (not required by anybackend)
X11-xcbfunctions: yes
XCB-shmfunctions: yes
The following features and utilities:
cairo-trace: yes
cairo-script-interpreter: yes
And the following internal features:
pthread: yes
gtk-doc: no
gcovsupport: no
symbol-lookup: no (requires bfd)
testsurfaces: no (disabled, use --enable-test-surfaces to enable)
pstesting: no (requires libspectre)
pdftesting: no (requires poppler-glib>= 0.17.4)
svgtesting: no (requires librsvg-2.0 >=2.35.0)
4.安裝pango
依賴關係:(a,b -> c c依賴於a,b):
(libffi-3.2,pcre-8.40 ) -> glib-2.48.2
(libpng-1.6.28,readline-6.3) ->freetype-2.5.4 -> fontconfig-2.12.0 -> harfbuzz-1.4.0 <-(icu4c-50_1,glib-2.48.2)
harfbuzz-1.4.0 -> pango-1.40.2
1)編譯libpng-1.6.28
rpm-ivh --nodeps zlib-devel-1.2.7-7.1.1.x86_64.rpm --freetype需要
./configure --prefix=/usr/local
make
make install
2)編譯readline-6.3
./configure --prefix=/usr/local
make
make install
3)安裝freetype-2.5.4
./configure --prefix=/usr/local
make
make install
4)編譯fontconfig-2.12.0
rpm-ivh --nodeps libxml2-devel-2.7.6-0.23.1.x86_64.rpm --fontconfig需要
./configure --sysconfdir=/etc --prefix=/usr/local--mandir=/usr/share/man --enable-libxml2
make
make install
5)編譯icu4c-50_1
./configure --prefix=/usr/local
make
make install
6)編譯libffi-3.2
./configure --prefix=/usr/local
make
make install
7)編譯pcre-8.40
./configure --enable-utf8 --enable-unicode-properties--prefix=/usr/local
make
make install
8)編譯glib-2.48.2(最好是這個版本)
./configure --prefix=/usr/local
make
make install
9)編譯harfbuzz-1.4.0
./configure --prefix=/usr/local
make
make install
configure結果:
Unicode callbacks (you want at least one):
Glib: true
ICU: true
UCDN: false
10)編譯pango-1.40.2
./configure --prefix=/usr/local
make
make install
5.安裝R-3.2.2
依賴關係(a->b b依賴於a):
gmp-5.1.3 -> isl-0.13
mpfr-3.1.5 -> mpc-1.0.2
jpeg9b
tiff-4.0.7
1)安裝ncurses-devel(readline的依賴)
zypper in ncurses-devel
2)安裝gmp-5.1.3
./configure --prefix=/usr/local
make
make install
2)安裝isl-0.13
./configure --prefix=/usr/local
make
make install
3)安裝mpfr-3.1.5
./configure --prefix=/usr/local
make
make install
4)安裝mpc-1.0.2
./configure --prefix=/usr/local
make
make install
5)安裝jpeg-9b
./configure --prefix=/usr/local
make
make install
6)安裝tiff-4.0.7
./configure --prefix=/usr/local
make
make install
7)安裝R-3.2.2
./configure --enable-R-shlib --with-readline=yes --with-jpeglib=yes--with-libpng=yes --with-x=yes --with-libtiff=yes --with-cairo=yes--with-ICU=yes --prefix=/opt/R
make (如果沒有java環境還需要安裝java)
make install
8)vi /etc/profile
export PATH=$PATH:/opt/gcc-trunk/bin:/opt/R/bin
source /etc/profiel
可以開始使用R了
R
> capabilities()
jpeg png tiff tcltk X11 aqua
TRUE TRUE TRUE FALSE FALSE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE TRUE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE FALSE TRUE TRUE TRUE FALSE
option
R安裝ggplot2
https://cran.r-project.org/web/packages/available_packages_by_name.html
依賴於:
digest, gtable (≥ 0.1.1), plyr (≥ 1.7.1),reshape2, scales (≥ 0.4.1), tibble, lazyeval
Rcpp -> plyr
stringi,magrittr -> stringr -> reshape2
lazyeval,assertthat -> tibble
RColorBrewer,dichromat,(colorspace -> munsell),labeling -> scales
1)R CMD INSTALL digest_0.6.12.tar.gz
2)R CMD INSTALL gtable_0.2.0.tar.gz
3)R CMD INSTALL Rcpp_0.12.9.tar.gz
4)R CMD INSTALL plyr_1.8.4.tar.gz
5)R CMD INSTALL stringi_1.1.2.tar.gz
6)R CMD INSTALL magrittr_1.5.tar.gz
7)R CMD INSTALL stringr_1.2.0.tar.gz
8)R CMD INSTALL reshape2_1.4.2.tar.gz
9)R CMD INSTALL lazyeval_0.2.0.tar.gz
10)R CMD INSTALL assertthat_0.1.tar.gz
11)R CMD INSTALL tibble_1.2.tar.gz
12)R CMD INSTALL RColorBrewer_1.1-2.tar.gz
13)R CMD INSTALL dichromat_2.0-0.tar.gz
14)R CMD INSTALL colorspace_1.3-2.tar.gz
15)R CMD INSTALL munsell_0.4.3.tar.gz
16)R CMD INSTALL labeling_0.3.tar.gz
17)R CMD INSTALL scales_0.4.1.tar.gz
18)R CMD INSTALL ggplot2_2.2.1.tar.gz
R
>library()
Packages in library ‘/opt/R/lib64/R/library’:
KernSmooth Functions for Kernel SmoothingSupporting Wand
& Jones (1995)
MASS Support Functions andDatasets for Venables and
Ripley's MASS
Matrix Sparse and Dense MatrixClasses and Methods
RColorBrewer ColorBrewer Palettes
Rcpp Seamless R and C++ Integration
assertthat Easy pre and post assertions.
base The R Base Package
boot Bootstrap Functions(Originally by Angelo Canty
for S)
class Functions for Classification
cluster "Finding Groups inData": Cluster Analysis
Extended Rousseeuw etal.
codetools Code Analysis Tools for R
colorspace Color Space Manipulation
compiler The R Compiler Package
datasets The R Datasets Package
dichromat Color Schemes for Dichromats
digest Create Compact Hash Digestsof R Objects
foreign Read Data Stored by Minitab,S, SAS, SPSS,
Stata, Systat, Weka,dBase, ...
ggplot2 Create Elegant DataVisualisations Using the
Grammar of Graphics
FAQ
在安裝R的過程中遇到的一些問題
1. R依賴
R官方網站說明:
The ‘modern’ version of the X11(), jpeg(),png() and tiff() graphics devices uses the cairo and (optionally) Pangolibraries.
Cairo version 1.2.0 or later is required.
Pango needs to be at least version 1.10,and 1.12 is the earliest version we have tested.
(For Fedora users we believe thepango-devel RPM and its dependencies suffice.)
R checks for pkg-config, and uses that tocheck first that the ‘pangocairo’ package is installed (and if not, ‘cairo’)
and if additional flags are needed for the‘cairo-xlib’ package,
then if suitable code can be compiled.
These tests will fail if pkg-config is notinstalled48,
and are likely to fail if cairo was builtstatically (unusual).
Most systems with Gtk+ 2.8 or laterinstalled will have suitable libraries
需要pango和cairo,並且cairo需要cairo-xlib支援
2. --with-x=yes (default) andX11 headers/libs are not available
編譯R時報錯:
checking X11/Intrinsic.h usability... no
checking X11/Intrinsic.h presence... no
checking for X11/Intrinsic.h... no
configure: error: --with-x=yes (default)and X11 headers/libs are not available
解決辦法: install libXt
3. dchdc.o: could not readsymbols: Bad value
make R時報錯:
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld:
../appl/dchdc.o: relocation R_X86_64_32against `.rodata' can not be used when making a shared object; recompile with-fPIC
../appl/dchdc.o: could not read symbols:Bad value
collect2: ld returned 1 exit status
解決辦法: configura時去掉--enable-R-shlib
4. error: cairo-xlib.h: No suchfile or directory
編譯R時報錯:
configure:31534: checking for X
configure:31720: result: disabled
configure:32391: result: using X11 ... no
configure:32501: checking whetherpkg-config knows about cairo and pango
configure:32513: result: yes
configure:32547: checking whether cairoincluding pango is >= 1.2 and works
configure:32570: gcc -std=gnu99 -o conftest-g -O2 -fpic -I/usr/local/include -I/usr/include/libxml2-I/usr/local/include/pango-1.0 -I/usr/local/include/cairo-I/usr/local/include/harfbuzz -I/usr/local/include/freetype2-I/usr/local/include -I/usr/local/include/glib-2.0-I/usr/local/lib/glib-2.0/include -I/usr/local/include/pixman-1 -I/usr/local/include/libpng16 -L/usr/local/lib64 conftest.c -lrt -ldl-lm -L/usr/local/lib -lpangocairo-1.0-lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpng16 -lz -lcairo >&5
conftest.c:233:24: error: cairo-xlib.h: Nosuch file or directory
configure:32570: $? = 1
解決辦法:這是安裝了cairo,但是編譯cairo時沒有加--enable-xlib=yes引數
5. /libreadline.so: undefined reference to….
configure R時候readline報錯,檢視config.log:
configure:20905: checking forrl_callback_read_char in -lreadline
configure:20930: gcc -o conftest -g -O2-I/usr/local/include -L/usr/local/lib64 conftest.c -lreadline >&5
/usr/local/lib/libreadline.so: undefinedreference to `tputs'
/usr/local/lib/libreadline.so: undefinedreference to `tgoto'
/usr/local/lib/libreadline.so: undefinedreference to `tgetflag'
/usr/local/lib/libreadline.so: undefinedreference to `UP'
/usr/local/lib/libreadline.so: undefinedreference to `tgetent'
/usr/local/lib/libreadline.so: undefinedreference to `tgetnum'
/usr/local/lib/libreadline.so: undefinedreference to `PC'
/usr/local/lib/libreadline.so: undefinedreference to `tgetstr'
/usr/local/lib/libreadline.so: undefinedreference to `BC'
collect2: ld returned 1 exit status
configure:20930: $? = 1
解決辦法: zypper in ncurses-devel
6. error: cannot compile a simple Fortranprogram
configure R 時候報錯:
checking for Fortran 77 libraries ofgfortran...
checking how to get verbose linking outputfrom gcc -std=gnu99... -v
checking for C libraries of gcc-std=gnu99... -L/usr/local/lib64-L/usr/lib64/gcc/x86_64-suse-linux/4.3 -L/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64-L/lib/../lib64 -L/usr/lib/../lib64-L/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/lib-L/usr/lib64/gcc/x86_64-suse-linux/4.3/../../.. -lgcc_s
checking for dummy main to link withFortran 77 libraries... none
checking for Fortran 77 name-manglingscheme... configure: error: in `/soft/R-3.2.2':
configure: error: cannot compile a simpleFortran program
config.log中搜尋"cannotcompile a simple Fortran program":
configure:23745: checking for Fortran 77name-mangling scheme
configure:23758: gfortran -c conftest.f >&5
/opt/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.0.0/f951:error while loading shared libraries: libisl.so.13: cannot open sh
ared object file: No such file or directory
configure:23758: $? = 1
configure: failed program was:
| subroutine foobar()
| return
| end
| subroutine foo_bar()
| return
| end
configure:23891: error: in `/soft/R-3.2.2':
configure:23893: error: cannot compile asimple Fortran program
解決辦法:安裝isl
7. undefined reference to….
make R時報錯
gcc -std=gnu99 -Wl,--export-dynamic-fopenmp -L../../lib -L/usr/local/lib64-o R.bin Rmain.o -lR -lRblas
/opt/gcc-trunk/lib64/libgfortran.so.4:undefined reference to `__cpu_model@GCC_4.8.0'
collect2: ld returned 1 exit status
make[3]: *** [R.bin] Error 1
解決辦法:
/etc/profile裡新增:
exportLIBRARY_PATH=$LIBRARY_PATH:/opt/gcc-trunk/lib:/opt/gcc-trunk/lib64
source /etc/profile
相關文章