【发布时间】:2021-10-05 06:05:13
【问题描述】:
我需要在我自己的目录中的公共服务器上安装最新的 R 版本 4.1.1。 我遵循了这个程序:
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"
The configure seemed to work:
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
but when I call
make && make install
still "make" could not make it until the end:
...
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
Follow up:
Based on thrig 's suggestion, I added the lines below to my .cshrc file
setenv LD_LIBRARY_PATH $HOME/Programme/pcre-8.40/lib
setenv LD_LIBRARY_PATH $HOME/Programme/xz-5.2.3/lib
and
source .cshrc
problem solved!
Best Answer
This is the solution to the issue mentioned above
Follow the example to modify the configure file of R Then:
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
make
make install PREFIX=$HOME/Programme/bzip2-1.0.6
tar zxvf xz-5.2.3.tar.gz
cd xz-5.2.3
./configure --prefix=$HOME/Programme/xz-5.2.3
make -j3
make install
tar zxvf pcre-8.40.tar.gz
cd 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 curl-7.52.1
./configure --prefix=$HOME/Programme/curl-7.52.1 --with-ssl
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"
Add the lines below to my .cshrc file
setenv LD_LIBRARY_PATH $HOME/Programme/pcre-8.40/lib
setenv LD_LIBRARY_PATH $HOME/Programme/xz-5.2.3/lib
and
source .cshrc
Now go to R-3.3.1 directory:
make && make install
it should work.
Related Question
Install R in the own directory
Ubuntu – How tonstall R’s devtools and digitize
...经过一些修改,我最终的实际代码是:
./configure --prefix=$HOME/Programme/R-4.1.1 --enable-R-shlib --with-readline=no LDFLAGS="-L/$HOME/Programme/zlib-1.2.11/lib -L/$HOME/Programme/bzip2-1.0.6/lib -L/$HOME/Programme/xz-5.2.4/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.4/include -I/$HOME/Programme/pcre-8.40/include -I/$HOME/Programme/curl-7.52.1/include" --with-x=no --with-pcre1
但是,我无法修改 .cshrc 文件,因为我猜它是一个公共服务器,并且我无法修改 LD_LIBRARY_PATH。 我仍然收到此错误:
/usr/bin/ld:警告:libpcre.so.1,../../lib/libR.so 需要,未找到(尝试使用 -rpath 或 -rpath-link) /usr/bin/ld:警告:liblzma.so.5,../../lib/libR.so 需要,未找到(尝试使用 -rpath 或 -rpath-link)
有什么建议可以让编译器在不编辑 .cshrc 文件的情况下识别这些依赖关系?
【问题讨论】:
-
你可以访问这台机器上的 Docker 吗?你真的想编译它还是只是安装一个二进制文件?旧版本的 gcc 和操作系统会经常遇到
LD_PATH问题。 -
我想我可能有访问权限,我想我需要编译它
-
没有使用任何非常特殊的编译器标志。你真的关心最大优化的系统还是你有非常特殊的硬件?对于 99% 的用例,根本不需要编译任何东西。统计工作流程应该是可重现的并且具有系统级别的依赖性(在您的情况下是 curl 和 zlib)。然后我们可以使用 docker 作为包管理器,并使用
docker run -it --network host -v $HOME:/home/rstudio rocker/r-ver:4.1.1 R创建一个全新的预编译 R 容器 -
您真的需要 xz 和 pcre 的精确版本吗?