Configuration and installation of R language in Linux environment

When doing scientific computing, R language is sometimes used as an auxiliary (there are many computing modules),
but because the server version of R language version is too old (many cannot be packaged), and it does not have sudo permission or root account, so choose the local account. Install the R language under

1. Download and unzip the package
wget https://cran.r-project.org/src/base/R-3/R-3.4.4.tar.gz
tar xavf R-3.4.4.tar.gz
cd R-3.4.4.tar.gz
2. Configure and compile
./configure --enable-R-shlib --with-readline=yes --with-libpng=yes --with-blas --prefix=/your/path

Command explanation: where

  • –enable-R-shlib means to generate the libR.so library, which is very important when compiling with gcc, etc.
  • --with-readline=yes indicates that it is used for debugging optimization under R shell conditions, it is recommended to add
  • --with-libpng=yes means that png images can be exported
  • --with-blas means to optimize R operations and generate libRblas.so library
  • --prefix ensures that the final installation can be completed, otherwise make install will install it to the /usr/lib folder, and non-root users have no permissions
3. Updates for missing dependencies

When the software required by the system is incomplete or the version is too low, an error will still be reported. Generally, the common error is that bzip2, zlib, pcre, curl, xz, etc. are missing. The
general method only needs to install the software header files, dynamic link library files, executable The file path can be added to the compilation path, but there are several points to note

  • bzip2 install
修改Makefile文件
CC=gcc 改为
CC=gcc -fPIC

之后再进行
make
make install -prefix=/your/path
  • pcre install
直接安装后,配置R报错
checking pcre/pcre.h usability... no
checking pcre/pcre.h presence... no
checking for pcre/pcre.h... no
checking if PCRE version >= 8.20, < 10.0 and has UTF-8 support... no
checking whether PCRE support suffices... configure: error: pcre >= 8.20 library and headers are required

因此安装pcre时,编译有特殊要求
./configure --enable-utf8 --enable-unicode-properties --prefix=/your/path


  • The environment
    variables set LD_LIBRARY_PATH, C_INCLUDE_PATH, CPLUS_INCLUDE_PATH at first but didn't work The
    reason is

The environment variables of C_INCLUDE_PATH (for C header files) and CPLUS_INCLUDE_PATH (for C++ header files) are the search paths for specifying header files. The header files specified by these two environment variables will be searched after the path specified by -I and before the system default path. LIBRARY_PATH specifies the library search path. This environment variable specifies that the path will be searched after the -L specified path and before the system default path.
Therefore, the system default path can only be overridden by adding the -L -I parameter
4. Final compilation
./configure --prefix=/your/path  --enable-R-shlib  --with-readline=yes --with-libpng=yes --with-blas  LDFLAGS="-L/your/path/lib" CPPFLAGS="-I/your/path/include"

can be successfully completed

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324451404&siteId=291194637