简体   繁体   English

无法安装 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

I'm having trouble installing the "car" package after upgrading R to 3.6.2 (from 3.4) on Ubuntu 16.04 due to (at least one) dependency (nloptr) that cannot be installed either.在 Ubuntu 16.04 上将 R 升级到 3.6.2(从 3.4)后,由于(至少一个)依赖项(nloptr)无法安装,我在安装“car”包时遇到问题。 It seems to be a problem of the C++ compiler (it is using some deprecated "config" settings, however I'm lost trying to fix this).这似乎是 C++ 编译器的问题(它使用了一些不推荐使用的“配置”设置,但是我在尝试解决这个问题时迷失了方向)。

I called the following command in R (from the terminal):我在 R 中调用了以下命令(从终端):

install.packages("nloptr") install.packages("nloptr")

Error Information:错误信息:

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’

Steps taken so far迄今为止采取的步骤

  • changed CRAN mirror and source.list entry更改了 CRAN 镜像和 source.list 条目
  • uninstalled and reinstalled R 3.6.2 (also on different machine), same issue remained卸载并重新安装 R 3.6.2(也在不同的机器上),同样的问题仍然存在

System Information系统信息

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

We have done a lot of work to make nloptr installation better.我们做了很多工作来使 nloptr 安装更好。 In essence, you have several choices:本质上,您有几种选择:

  • if the system version of the nlopt library is present, use it -- that is the easiest so try installing it via sudo apt-get install libnlopt-dev and then reinstall如果存在 nlopt 库的系统版本,请使用它——这是最简单的,所以尝试通过sudo apt-get install libnlopt-dev安装它,然后重新安装

  • if it is not found, then a download of the source and build happens, and this seems to fail on your almost four year old Ubuntu system as it is hard to support all flavours --- but this works swimmingly on newer ones (I run Ubuntu too, but currently 19.10)如果没有找到,那么就会下载源代码并进行构建,这似乎在你将近四年前的 Ubuntu 系统上失败了,因为它很难支持所有风格——但这在较新的系统上运行良好(我运行Ubuntu 也是,但目前是 19.10)

  • there are binaries for you as, see the Ubuntu packages page -- however these may not match your current R version which is mismatches to your distro R version有二进制文件供您使用,请参阅Ubuntu 软件包页面——但是这些可能与您当前的 R 版本不匹配,这与您的发行版 R 版本不匹配

  • dependening on where you got R from (did you install a .deb?) you could use the Michael Rutter PPAs to get a current r-cran-nloptr取决于您从哪里获得 R(您是否安装了 .deb?),您可以使用 Michael Rutter PPA 来获取当前的r-cran-nloptr

All this can also be discussed in detail on the r-sig-debian list for R on Debian and Ubuntu.所有这些也可以在 Debian 和 Ubuntu 上的 R 的 r-sig-debian 列表中详细讨论。

Edit: In response to the comment below:编辑:回应以下评论:

  • To see what package apt knows about, do apt-cache policy r-cran-nloptr .要查看apt知道什么包,请执行apt-cache policy r-cran-nloptr Per the link I gave above we know Ubuntu has a r-cran-nloptr for your (very old) Xenial installation.根据我上面给出的链接,我们知道Ubuntu 有一个r-cran-nloptr用于您的(非常旧的)Xenial 安装。 However it will clash with the very new and current R you have running.但是,它会与您正在运行的最新的和当前的 R 发生冲突。 Such as the costs of mixing and matching.比如混搭的成本。

  • To access the Rutter PPAs and its over four thousand current binaries see the fourth paragraph at the top of the Ubuntu at CRAN README要访问 Rutter PPA 及其四千多个当前二进制文件,请参阅CRAN README 中 Ubuntu顶部的第四段

Edit 2: I may have been too pessimistic.编辑2:我可能太悲观了。 The Rutter PPA for the current R binaries has trusty, xenial and bionic.当前 R 二进制文件的 Rutter PPA 具有可信赖的、xenial 和仿生的。 See https://launchpad.net/~marutter/+archive/ubuntu/c2d4u3.5https://launchpad.net/~marutter/+archive/ubuntu/c2d4u3.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM