R 安装报错问题(解决lib的缺少和版本问题)

  • Post author:
  • Post category:其他


redhat6 上编译安装R语言:版本:3.3.2

1) 下载:

R-3.3.2.tar.gz(https://mirrors.tuna.tsinghua.edu.cn/CRAN/    点击:R-3.3.2.tar.gz 下载:最新版!)

2)安装:

解压:

cd /software

tar -zxvf R-3.3.2.tar.gz

mkdir -p  /home/liyg/software/R

cd R-3.3.2

./configure –prefix=/home/liyg/software/R –enable-R-shlib

3) 报错和解决方法:./configure –prefix=/home/liyg/software/R –enable-R-shlib

a) 报错如下:

configure:5783: result: no

configure:5846: checking for cc

configure:5893: result: no

configure:5949: checking for cl.exe

configure:5979: result: no

configure:6003: error: in `/software/R-3.3.2′:

configure:6005: error: no acceptable C compiler found in $PATH

See `config.log’ for more details

解决方法:yum install gcc

b) 报错如下:

checking for fc… no

configure: error: No F77 compiler found

解决方法:yum install gcc-gfortran

c)报错如下:

checking how to run the C++ preprocessor… /lib/cpp

configure: error: in `/software/R-3.3.2′:

configure: error: C++ preprocessor “/lib/cpp” fails sanity check

See `config.log’ for more details

解决方法:yum install gcc gcc-c++

d)报错如下:

–with-readline=yes (default) and headers/libs are not available

解决方法:yum install readline-devel

e)报错如下:

–with-x=yes (default) and X11 headers/libs are not available

解决方法:yum install libXt-devel

f)报错如下:

checking for rpc/xdr.h… yes

checking for XDR support… yes

checking for inflateInit2_ in -lz… no

checking whether zlib support suffices… configure: error: zlib library and headers are required

解决方法:yum install zlib-devel

yum -y install bzip2-devel

g)报错如下:zlib版本太低!

checking if zlib version >= 1.2.5… no

checking whether zlib support suffices… configure: error: zlib

library and headers are required

解决方法:下载:http://zlib.net/zlib-1.2.8.tar.gz

tar xzvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure –prefix=$HOME/packages

设置环境变量:

export PATH=/software/packages/bin:$PATH

export LD_LIBRARY_PATH=/software/packages/lib:$LD_LIBRARY_PATH

export CFLAGS=”-fPIC -I/software/packages/include”

export LDFLAGS=”-fPIC -L/software/packages/lib”

h) 报错如下:bzip2 版本太低

checking bzlib.h presence… yes

checking for bzlib.h… yes

checking if bzip2 version >= 1.0.6… no

checking whether bzip2 support suffices… configure:

error: bzip2 library and headers are required

解决方法:下载:http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz

tar -zxvf bzip2-1.0.6.tar.gz

cd bzip2-1.0.6

make

make install PREFIX=/software/packages

make -f Makefile-libbz2_so   //建立共享library,可能会报错!后面有解决方法!

i) 报错如下:

checking for lzma_version_number in -llzma… no

configure: error: “liblzma library and headers are required”

解决方法:yum -y install xz-devel.x86_64

j)报错如下:版本太低

checking if lzma version >= 5.0.3… no

configure: error: “liblzma library and headers are required”

解决方法:下载: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=/software/packages

make -j3

make install

k)报错如下:版本太低

checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support… no

checking whether PCRE support suffices… configure: error: pcre >= 8.10 library and headers are required

解决方法:下载: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 –prefix=/software/packages

make -j3

make install

l)报错如下:编码不对

checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support… no

checking whether PCRE support suffices… configure: error: pcre >= 8.10 library and headers are required

解决方法:    cd pcre-8.38

./configure –enable-utf8 –prefix=/software/packages

make

make install

m)错误如下:

checking for curl-config… no

checking curl/curl.h usability… no

checking curl/curl.h presence… no

checking for curl/curl.h… no

configure: error: libcurl >= 7.28.0 library and headers are required with support for https

解决办法:下载: https://curl.haxx.se/download/curl-7.47.1.tar.gz

./configure –prefix=/software/packages

make -j3

make install

n)错误如下:https是安全的需要安装:openssl

checking if libcurl is version 7 and >= 7.28.0… yes

checking if libcurl supports https… no

configure: error: libcurl >= 7.28.0 library and headers are required with support for https

解决方法:下载:openssl-1.0.1u.tar.gz

tar -xzvf openssl-1.0.1u.tar.gz

cd openssl-1.0.1u

./config -fPIC –prefix=/usr/local/openssl enable-shared

./config -t

make && make install

设置环境变量: export OPENSSL=/usr/local/openssl/bin

export PATH=$OPENSSL:$PATH:$HOME/bin

重新安装curl:指定openssl

./configure –prefix=/software/packages –with-openssl-include=/usr/local/openssl/include/ –with-openssl-lib=/usr/local/openssl/lib

make -j3

make install

4)重新编译:

cd R-3.3.2

./configure –prefix=/home/liyg/software/R –enable-R-shlib

编译成功:结果如下:

Source directory:          .

Installation directory:    /home/liyg/software/R

C compiler:                gcc -std=gnu99  -I/software/packages/include

Fortran 77 compiler:       gfortran  -g -O2

C++ compiler:              g++  -g -O2

C++11 compiler:            g++  -std=c++0x -g -O2

Fortran 90/95 compiler:    gfortran -g -O2

Obj-C compiler:

Interfaces supported:      X11

External libraries:        readline, curl

Additional capabilities:   NLS

Options enabled:           shared R library, shared BLAS, R profiling

Capabilities skipped:      PNG, JPEG, TIFF, cairo, ICU

Options not enabled:       memory profiling

Recommended packages:      yes

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 vignettes and help pages

5)执行编译: make

报错如下:

gcc -std=gnu99 -shared -fopenmp -L/software/packages/lib  -o libR.so CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o arithmetic.o array.o attrib.o bind.o builtin.o character.o coerce.o colors.o complex.o connections.o context.o cum.o dcf.o datetime.o debug.o deparse.o devices.o dotcode.o dounzip.o dstruct.o duplicate.o edit.o engine.o envir.o errors.o eval.o format.o gevents.o gram.o gram-ex.o graphics.o grep.o identical.o inlined.o inspect.o internet.o iosupport.o lapack.o list.o localecharset.o logic.o main.o mapply.o match.o memory.o names.o objects.o options.o paste.o platform.o plot.o plot3d.o plotmath.o print.o printarray.o printvector.o printutils.o qsort.o radixsort.o random.o raw.o registration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o sort.o source.o split.o sprintf.o startup.o subassign.o subscript.o subset.o summary.o sysutils.o times.o unique.o util.o version.o g_alab_her.o g_cntrlify.o g_fontdb.o g_her_glyph.o xxxpr.o   `ls ../unix/*.o ../appl/*.o ../nmath/*.o` ../extra/tre/libtre.a    -L../../lib -lRblas -lgfortran -lm   -lreadline  -lpcre -llzma -lbz2 -lz -lrt -ldl -lm

/usr/bin/ld: /software/packages/lib/libbz2.a(bzlib.o): relocation R_X86_64_32S against `.text’ can not be used when making a shared object; recompile with -fPIC

/software/packages/lib/libbz2.a: could not read symbols: Bad value

collect2: ld returned 1 exit status

make[3]: *** [libR.so] Error 1

make[3]: Leaving directory `/software/R-3.3.2/src/main’

make[2]: *** [R] Error 2

make[2]: Leaving directory `/software/R-3.3.2/src/main’

make[1]: *** [R] Error 1

make[1]: Leaving directory `/software/R-3.3.2/src’

make: *** [R] Error 1

-fPIC –prefix=/usr/local/openssl enable-shared

解决方法:重新编译安装libbz2!并指定 -fPIC!!!共享library

步骤:

第一:设置环境变量:注意:CFLAGS和LDFLAGS 加上 -fPIC  如下:

export PATH=/software/packages/bin:$PATH

export LD_LIBRARY_PATH=/software/packages/lib:$LD_LIBRARY_PATH

export CFLAGS=”-fPIC -I/software/packages/include”

export LDFLAGS=”-fPIC  -L/software/packages/lib”

第二:指定-fPIC编译:重新编译步骤:h)

cd bzip2-1.0.6

make CC=’gcc -fPIC’

make install PREFIX=/software/packages

make -f Makefile-libbz2_so   //建立共享library,不会报错说明正确

第三:重新编译R:

cd /software/R-3.3.2

./configure –prefix=/home/liyg/software/R –enable-R-shlib

make  //需要等比较长时间

结果:终于编译成功!!!!!太不容易了!!

结果信息如下:

trying to compile and link a JNI program

detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux

detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm

make[2]: Entering directory `/tmp/Rjavareconf.BzLkuk’

gcc -std=gnu99 -I/software/R-3.3.2/include -DNDEBUG -I/usr/java/jdk1.7.0_67-cloudera/include -I/usr/java/jdk1.7.0_67-cloudera/include/linux -I/usr/local/include    -fpic  -fPIC -I/software/packages/include  -c conftest.c -o conftest.o

gcc -std=gnu99 -shared -L/software/R-3.3.2/lib -fPIC -L/software/packages/lib -o conftest.so conftest.o -L/usr/java/jdk1.7.0_67-cloudera/jre/lib/amd64/server -ljvm -L/software/R-3.3.2/lib -lR

make[2]: Leaving directory `/tmp/Rjavareconf.BzLkuk’

JAVA_HOME        : /usr/java/jdk1.7.0_67-cloudera

Java library path: $(JAVA_HOME)/jre/lib/amd64/server

JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux

JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm

Updating Java configuration in /software/R-3.3.2

Done.

make[1]: Leaving directory `/software/R-3.3.2′

6) 执行make install 即可:

结果如下:

make[3]: Leaving directory `/software/R-3.3.2/src/modules/internet’

make[3]: Entering directory `/software/R-3.3.2/src/modules/lapack’

make[3]: Leaving directory `/software/R-3.3.2/src/modules/lapack’

make[3]: Entering directory `/software/R-3.3.2/src/modules/X11′

make[3]: Leaving directory `/software/R-3.3.2/src/modules/X11′

make[2]: Leaving directory `/software/R-3.3.2/src/modules’

make[2]: Entering directory `/software/R-3.3.2/src/library’

mkdir -p — /home/liyg/software/R/lib64/R/library

installing packages …

building HTML index …

make[2]: Leaving directory `/software/R-3.3.2/src/library’

make[1]: Leaving directory `/software/R-3.3.2/src’

make[1]: Entering directory `/software/R-3.3.2/tests’

make[1]: Nothing to be done for `install’.

make[1]: Leaving directory `/software/R-3.3.2/tests’