这是一个有点重复的问题(请参阅如何在我的目录中安装R设置PATH),但是我确实遇到了新版本R的一些新问题。
我试图在自己的目录中安装R(R 3.3.1)的新版本。我遵循了以前的安装流程
但是我遇到了一个前所未有的问题。
./configure --prefix=$HOME/Programme/R-3.3.1
.......
checking for zlib.h... yes
checking if zlib version >= 1.2.5... no
checking whether zlib support suffices... configure: error: zlib library and headers are required
看来zlib版本太低,所以我安装了当前版本的zlib
tar xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=$HOME/Programme/zlib-1.2.11
make && make install
然后我尝试再次为R做配置,例如:
./configure --prefix=$HOME/Programme/R-3.3.1 --enable-R-shlib LDFLAGS="-L/$HOME/Programme/zlib-1.2.11/lib" CPPFLAGS="-I/$HOME/Programme/zlib-1.2.11/include"
仍然我有同样的错误:
checking if zlib version >= 1.2.5... no
checking whether zlib support suffices... configure: error: zlib library and headers are required
然后我注意到有人通过修改R的配置文件来规避该问题,
我跟随该示例解决了zlib错误。但随后出现其他错误。简而言之,我安装了其他依赖库
tar xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=$HOME$Programme/zlib-1.2.11
make && make install
tar zxvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make -f Makefile-libbz2_so
make clean
# modify the Makefile (original: CC=gcc after modification: CC=gcc -fPIC) as suggested [here][2]
make
make install PREFIX=/opt/bzip2-1.0.6
tar zxvf xz-5.2.3.tar.gz
cd /root/xz-5.2.3
./configure --prefix=$HOME/Programme/xz-5.2.3
make -j3
make install
tar zxvf pcre-8.40.tar.gz
cd /root/pcre-8.40
./configure --prefix=$HOME/Programme/pcre-8.40 --enable-utf8
make -j3 && make install
tar zxvf curl-7.52.1.tar.gz
cd /root/curl-7.52.1
./configure --prefix=$HOME/Programme/curl-7.52.1
make && make install
./configure --prefix=$HOME/Programme/R-3.3.1 --enable-R-shlib LDFLAGS="-L/$HOME/Programme/zlib-1.2.11/lib -L/$HOME/Programme/bzip2-1.0.6/lib -L/$HOME/Programme/xz-5.2.3/lib -L/$HOME/Programme/pcre-8.40/lib -L/$HOME/Programme/curl-7.52.1/lib" CPPFLAGS="-I/$HOME/Programme/zlib-1.2.11/include -I/$HOME/Programme/bzip2-1.0.6/include -I/$HOME/Programme/xz-5.2.3/include -I/$HOME/Programme/pcre-8.40/include -I/$HOME/Programme/curl-7.52.1/include"
配置似乎起作用:
R is now configured for x86_64-pc-linux-gnu
Source directory: .
Installation directory: $HOME/Programme/R-3.3.1
C compiler: gcc -std=gnu99 -g -O2
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, tcltk
External libraries: readline, curl
Additional capabilities: PNG, JPEG, NLS, cairo, ICU
Options enabled: shared R library, shared BLAS, R profiling
Capabilities skipped: TIFF
Options not enabled: memory profiling
Recommended packages: yes
但是当我打电话
make && make install
直到最后,“ make”仍然无法实现:
...
gcc -std=gnu99 -Wl,--export-dynamic -fopenmp -L../../lib -L//HOME/Programme/zlib-1.2.11/lib -L//HOME/Programme/bzip2-1.0.6/lib -L//HOME/Programme/xz-5.2.3/lib -L//HOME/Programme/pcre-8.40/lib -L//HOME/Programme/curl-7.52.1/lib -o R.bin Rmain.o -lR -lRblas
/usr/bin/ld: warning: libpcre.so.1, needed by ../../lib/libR.so, not found (try using -rpath or -rpath-link)
/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 `pcre_fullinfo'
../../lib/libR.so: undefined reference to `lzma_lzma_preset@XZ_5.0'
../../lib/libR.so: undefined reference to `lzma_alone_decoder@XZ_5.0'
../../lib/libR.so: undefined reference to `lzma_crc64@XZ_5.0'
../../lib/libR.so: undefined reference to `lzma_raw_encoder@XZ_5.0'
../../lib/libR.so: undefined reference to `pcre_config'
../../lib/libR.so: undefined reference to `lzma_code@XZ_5.0'
../../lib/libR.so: undefined reference to `lzma_stream_decoder@XZ_5.0'
../../lib/libR.so: undefined reference to `pcre_free'
../../lib/libR.so: undefined reference to `lzma_raw_decoder@XZ_5.0'
../../lib/libR.so: undefined reference to `pcre_exec'
../../lib/libR.so: undefined reference to `lzma_version_string@XZ_5.0'
../../lib/libR.so: undefined reference to `pcre_maketables'
../../lib/libR.so: undefined reference to `lzma_stream_encoder@XZ_5.0'
../../lib/libR.so: undefined reference to `pcre_compile'
../../lib/libR.so: undefined reference to `pcre_study'
../../lib/libR.so: undefined reference to `pcre_version'
../../lib/libR.so: undefined reference to `lzma_end@XZ_5.0'
collect2: error: ld returned 1 exit status
...
make: *** [R] Error 1
跟踪:根据thrig的建议,我在.cshrc文件中添加了以下几行
setenv LD_LIBRARY_PATH $HOME/Programme/pcre-8.40/lib
setenv LD_LIBRARY_PATH $HOME/Programme/xz-5.2.3/lib
和
source .cshrc
问题解决了!
@thrig,对不起,我没有正确输入我的配置信息,所以我对其进行了编辑以使其与我所做的完全相同。
—
君
对于“未找到”共享库,可以快速设置
—
thrig
LD_LIBRARY_PATH
为包括必要lib
目录。
如果是我,我将尝试安装具有通用前缀(例如
—
steeldriver
--prefix=/opt
(而不是单独的子目录--prefix=/opt/zlib-1.2.11
等))的依赖项,然后为pkg-config
例如export PKG_CONFIG_PATH=/opt/lib/pkgconfig:$PKG_CONFIG_PATH
在配置之前设置适当的搜索路径R
@thrig。TKS!有效!
—
君
--prefix=$HOME/Programme
和-L/$HOME/Programme/zlib-1.2.11/lib
看起来像两个不同的东西,这里是zlib的实际?(它是否附带*.pc
文件以便您可以使用pkg-config
?)