在 R 中安装软件包 'Rmpfr' 时出现非零的退出状态

4
我无法在R中安装Rmpfr包。我正在尝试使用CVXR包解决OR问题。由于Rmpfr包是必需的前提条件,我尝试使用install.packages('Rmpfr')进行安装。我遇到的错误是:
错误:无法为‘Rmpfr’加载软件包或名称空间,在dyn.load(file,DLLpath = DLLpath,...)中:无法加载共享对象'/home/karunyavenugopalan/R/x86_64-redhat-linux-gnu-library/3.6/00LOCK-Rmpfr/00new/Rmpfr/libs/Rmpfr.so':libmpfr.so.6:无法打开共享对象文件:没有那个文件或目录的错误:加载失败执行已停止错误:加载失败*删除'/home/karunyavenugopalan/R/x86_64-redhat-linux-gnu-library/3.6/Rmpfr'警告:安装包'Rmpfr'具有非零退出状态
操作系统:Fedora 31 RStudio版本:1.2.5019
我已经使用yum install mpfr-devel安装了mpfr。
请协助解决。
2个回答

4

如果您访问CRAN库中的Rmpfr部分,您会发现此软件包需要在安装R软件包之前安装gmpmpfr系统要求。

对于我在Fedora 30上的操作是,确保我已安装了-devel版本:

sudo dnf install gmp-devel mpfr-devel

首先我尝试安装该软件包:

$ R

R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("Rmpfr")
Installing package into ‘/home/romunov/R/x86_64-redhat-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
also installing the dependency ‘gmp’

trying URL 'https://cran.wu.ac.at/src/contrib/gmp_0.5-13.5.tar.gz'
Content type 'application/x-gzip' length 133364 bytes (130 KB)
==================================================
downloaded 130 KB

trying URL 'https://cran.wu.ac.at/src/contrib/Rmpfr_0.7-2.tar.gz'
Content type 'application/x-gzip' length 626031 bytes (611 KB)
==================================================
downloaded 611 KB

* installing *source* package ‘gmp’ ...
** package ‘gmp’ successfully unpacked and MD5 sums checked
** using staged installation
creating cache ./config.cache
checking for __gmpz_ui_sub in -lgmp... no
configure: error: GNU MP not found, or not 4.1.4 or up, see http://gmplib.org
ERROR: configuration failed for package ‘gmp’
* removing ‘/home/romunov/R/x86_64-redhat-linux-gnu-library/3.6/gmp’
ERROR: dependency ‘gmp’ is not available for package ‘Rmpfr’
* removing ‘/home/romunov/R/x86_64-redhat-linux-gnu-library/3.6/Rmpfr’

The downloaded source packages are in
    ‘/tmp/RtmpstRn5N/downloaded_packages’
Warning messages:
1: In install.packages("Rmpfr") :
  installation of package ‘gmp’ had non-zero exit status
2: In install.packages("Rmpfr") :
  installation of package ‘Rmpfr’ had non-zero exit status

安装gmp-devel

$ sudo dnf install gmp-devel
Last metadata expiration check: 0:59:19 ago on Tue 24 Dec 2019 09:44:08 AM CET.
Dependencies resolved.
=========================================================================================================================================================================
 Package                                 Architecture                         Version                                         Repository                            Size
=========================================================================================================================================================================
Installing:
 gmp-devel                               x86_64                               1:6.1.2-10.fc30                                 fedora                               173 k
Installing dependencies:
 gmp-c++                                 x86_64                               1:6.1.2-10.fc30                                 fedora                                17 k

Transaction Summary
=========================================================================================================================================================================
Install  2 Packages

Total download size: 191 k
Installed size: 402 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): gmp-c++-6.1.2-10.fc30.x86_64.rpm                                                                                                   36 kB/s |  17 kB     00:00    
(2/2): gmp-devel-6.1.2-10.fc30.x86_64.rpm                                                                                                214 kB/s | 173 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    107 kB/s | 191 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                 1/1 
  Installing       : gmp-c++-1:6.1.2-10.fc30.x86_64                                                                                                                  1/2 
  Installing       : gmp-devel-1:6.1.2-10.fc30.x86_64                                                                                                                2/2 
  Running scriptlet: gmp-devel-1:6.1.2-10.fc30.x86_64                                                                                                                2/2 
  Verifying        : gmp-c++-1:6.1.2-10.fc30.x86_64                                                                                                                  1/2 
  Verifying        : gmp-devel-1:6.1.2-10.fc30.x86_64                                                                                                                2/2 

Installed:
  gmp-devel-1:6.1.2-10.fc30.x86_64                                                     gmp-c++-1:6.1.2-10.fc30.x86_64                                                    

Complete!

抱歉,不够了。

> install.packages("Rmpfr")
Installing package into ‘/home/romunov/R/x86_64-redhat-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
also installing the dependency ‘gmp’

trying URL 'https://cran.wu.ac.at/src/contrib/gmp_0.5-13.5.tar.gz'
Content type 'application/x-gzip' length 133364 bytes (130 KB)
==================================================
downloaded 130 KB

trying URL 'https://cran.wu.ac.at/src/contrib/Rmpfr_0.7-2.tar.gz'
Content type 'application/x-gzip' length 626031 bytes (611 KB)
==================================================
downloaded 611 KB

* installing *source* package ‘gmp’ ...
** package ‘gmp’ successfully unpacked and MD5 sums checked
** using staged installation
creating cache ./config.cache
checking for __gmpz_ui_sub in -lgmp... yes
updating cache ./config.cache
creating ./config.status
creating src/Makevars
** libs
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I/usr/local/include/    -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -c apply.cc -o apply.o
...
checking mpfr.h presence... no
checking for mpfr.h... no
configure: error: Header file mpfr.h not found; maybe use --with-mpfr-include=INCLUDE_PATH
ERROR: configuration failed for package ‘Rmpfr’
* removing ‘/home/romunov/R/x86_64-redhat-linux-gnu-library/3.6/Rmpfr’

The downloaded source packages are in
    ‘/tmp/Rtmpaz2MNH/downloaded_packages’
Warning message:
In install.packages("Rmpfr") :
  installation of package ‘Rmpfr’ had non-zero exit status

安装 mpfr-devel

$ sudo dnf install mpfr-devel
Fedora Modular 30 - x86_64                                                                                                                21 kB/s |  23 kB     00:01    
Fedora Modular 30 - x86_64 - Updates                                                                                                      32 kB/s |  22 kB     00:00    
Fedora 30 - x86_64 - Updates                                                                                                              28 kB/s |  22 kB     00:00    
Fedora 30 - x86_64                                                                                                                        18 kB/s |  23 kB     00:01    
google-chrome-beta                                                                                                                        16 kB/s | 1.3 kB     00:00    
google-chrome                                                                                                                            3.4 kB/s | 1.3 kB     00:00    
RPM Fusion for Fedora 30 - Free - Updates                                                                                                 61 kB/s |  10 kB     00:00    
RPM Fusion for Fedora 30 - Free                                                                                                           12 kB/s |  10 kB     00:00    
RPM Fusion for Fedora 30 - Nonfree - Steam                                                                                                54 kB/s | 9.6 kB     00:00    
RPM Fusion for Fedora 30 - Nonfree - Updates                                                                                              51 kB/s |  10 kB     00:00    
RPM Fusion for Fedora 30 - Nonfree                                                                                                        61 kB/s |  11 kB     00:00    
Dependencies resolved.
=========================================================================================================================================================================
 Package                                   Architecture                          Version                                     Repository                             Size
=========================================================================================================================================================================
Installing:
 mpfr-devel                                x86_64                                3.1.6-4.fc30                                fedora                                 76 k

Transaction Summary
=========================================================================================================================================================================
Install  1 Package

Total download size: 76 k
Installed size: 122 k
Is this ok [y/N]: y
Downloading Packages:
mpfr-devel-3.1.6-4.fc30.x86_64.rpm                                                                                                       283 kB/s |  76 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                     66 kB/s |  76 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                 1/1 
  Installing       : mpfr-devel-3.1.6-4.fc30.x86_64                                                                                                                  1/1 
  Running scriptlet: mpfr-devel-3.1.6-4.fc30.x86_64                                                                                                                  1/1 
  Verifying        : mpfr-devel-3.1.6-4.fc30.x86_64                                                                                                                  1/1 

Installed:
  mpfr-devel-3.1.6-4.fc30.x86_64                                                                                                                                         

Complete!

再次尝试

> install.packages("Rmpfr")
Installing package into ‘/home/romunov/R/x86_64-redhat-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cran.wu.ac.at/src/contrib/Rmpfr_0.7-2.tar.gz'
Content type 'application/x-gzip' length 626031 bytes (611 KB)
==================================================
downloaded 611 KB

* installing *source* package ‘Rmpfr’ ...
** package ‘Rmpfr’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc -m64
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 accepts -g... yes
...
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (Rmpfr)

The downloaded source packages are in
    ‘/tmp/Rtmp4K9VTv/downloaded_packages’

3

Ubuntu的解决方案更新:

sudo apt install libgmp-dev
sudo apt-get install libmpfr-dev

之后,您可以在R中运行:

install.packages('gmp')
install.packages('Rmpfr')

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接