无法安装 R 包 "nloptr"(Ubuntu 16.04 上的 R3.6.2) - C++编译器问题

unable to install R package "nloptr" (R3.6.2 on Ubuntu 16.04) - C++ compiler issue

本文关键字:R3 问题 编译器 C++ 上的 安装 nloptr Ubuntu      更新时间:2023-10-16

在Ubuntu 16.04 上将 R 升级到 3.6.2(从 3.4(后,由于(至少一个(依赖项 (nloptr( 也无法安装,我在安装"car"包时遇到问题。这似乎是C++编译器的问题(它使用了一些已弃用的"配置"设置,但是我在尝试解决此问题时迷失了方向(。

我在 R 中调用了以下命令(从终端(:

install.packages("nloptr"(

错误信息:

Installing package into ‘/home/heike/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://ftp.fau.de/cran/src/contrib/nloptr_1.2.1.tar.gz'
Content type 'application/x-gzip' length 2448313 bytes (2.3 MB)
==================================================
downloaded 2.3 MB
* installing source package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
'config' variable 'CPP' is deprecated
'config' variable 'CXXCPP' is deprecated
checking whether the C++ compiler works... no
configure: error: in /tmp/RtmpPLaJFA/R.INSTALL5e5ed06eeac/nloptr': configure: error: C++ compiler cannot create executables See config.log' for more details
ERROR: configuration failed for package ‘nloptr’

迄今采取的步骤

  • 更改了 CRAN 镜像和源列表条目
  • 卸载并重新安装R 3.6.2(也在不同的计算机上(,仍然存在相同的问题

系统信息

  • 操作系统版本: Ubuntu 16.04 (x86_64-pc-linux-gnu(64位((
  • R 版本: 3.6.2 (2019-12-12(

我们做了很多工作来使nloptr安装更好。 从本质上讲,您有以下几种选择:

  • 如果存在 nlopt 库的系统版本,请使用它 - 这是最简单的,因此请尝试通过sudo apt-get install libnlopt-dev安装它,然后重新安装

  • 如果未找到,则下载源代码和构建,这似乎在您将近四年的 Ubuntu 系统上失败,因为很难支持所有口味---但这在较新的系统上运行良好(我也运行 Ubuntu,但目前为 19.10(

  • 有二进制文件供您使用,请参阅Ubuntu软件包页面 - 但是这些可能与您当前的R版本不匹配,该版本与您的发行版R版本不匹配

  • 根据你从哪里得到R(你安装了.deb吗?(,你可以使用Michael Rutter PPAs来获取当前的r-cran-nloptr

所有这些也可以在 Debian 和 Ubuntu 上的 R 的 r-sig-debian 列表中详细讨论。

编辑:回应以下评论:

  • 要查看apt知道的软件包,请apt-cache policy r-cran-nloptr。根据我上面给出的链接,我们知道Ubuntu 有一个r-cran-nloptr用于您的(非常旧的(Xenial 安装。但是,它会与您正在运行的非常新的和当前的 R 发生冲突。 比如混搭的成本。

  • 要访问 Rutter PPA 及其四千多个当前二进制文件,请参阅 CRAN README 中 Ubuntu 顶部的第四段

编辑2:我可能太悲观了。当前R二进制文件的Rutter PPA具有可信,xenial和仿生。请参阅 https://launchpad.net/~marutter/+archive/ubuntu/c2d4u3.5