Rcpp、Rtools 和 cygwin:无法安装 Rcpp

Rcpp, Rtools, and cygwin: failing to install Rcpp

首先尝试,在安装了 R 3.1.3 的 cygwin 中:

>PATH=/usr/local/bin:/usr/bin

在 R 中:

>install.packages("Rcpp",repos="http://cran.us.r-project.org")

产生错误

[...]
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lpcre
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -llzma
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lbz2
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lz
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -liconv
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licuuc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -licui18n
collect2: error: ld returned 1 exit status
/usr/lib/R/share/make/shlib.mk:6: recipe for target 'Rcpp.dll' failed
make: *** [Rcpp.dll] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/usr/lib/R/site-library/Rcpp’

所以我尝试安装 Rtools 3.2。按照 cygwin 安装的说明,我不安装 Rtools 中包含的 cygwin 的 dll。那么

>PATH=/cygdrive/c/Rtools/bin:/cygdrive/c/Rtools/gcc-4.6.3/bin:$PATH

在 R 中,当尝试进行安装时会产生静默非零状态退出

Installing package into ‘/usr/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/src/contrib/Rcpp_0.11.6.tar.gz'
Content type 'application/x-gzip' length 2352221 bytes (2.2 MB)
opened URL
==================================================
downloaded 2.2 MB


The downloaded source packages are in
        ‘/tmp/Rtmp71eoxd/downloaded_packages’
Warning message:
In install.packages("Rcpp", repos = "http://cran.us.r-project.org") :
  installation of package ‘Rcpp’ had non-zero exit status

详细模式没有提供更多信息。我搜索了很长时间,但我现在不知所措。有人有想法吗?谢谢

除非您有特定原因要使用 3.1.3,否则请将您的 R 更新到最新版本 (3.2.1)。

许多包甚至没有 Windows 二进制文件编译为最新的 R 版本,所以 99% 的时间,这解决了问题。

如果您只想安装 Rcpp,请尝试:

install.packages("Rcpp", type='source')

R 本身不支持 Cygwin,也从未支持过。

整整五年后编辑: 因为有人认为适合再次否决这个答案,请允许我引用 Section C.7 of the R Installation and Administration manual

C.7 Cygwin

The 32-bit version never worked well enough to pass R’s make check, and residual support from earlier experiments was removed in R 3.3.0.

The 64-bit version was never supported.

我没有更多要补充的了。我只是在他们自己的手册中重述了 R Core 对他们自己的软件的评价。

我对处理同样的错误感到沮丧。在 Cygwin 安装 'Select Packages' window 中,搜索每个库并安装它们。比如:pcre, lzma, bz2, ... 安装完这些终于可以编译了