【问题标题】:Cannot compile from source with Rcpp on Windows 7无法在 Windows 7 上使用 Rcpp 从源代码编译
【发布时间】:2016-10-16 18:45:22
【问题描述】:

我正在 Windows 7 虚拟机上运行 R 3.3 的新安装,并尝试安装我自己的使用 Rcpp 的 R 包。该软件包可在GitHub 获得。我已经安装了 Rtools 和 Rcppdevtools

使用devtools::install_github("pbsag/tcadr")

> devtools::install_github("pbsag/tcadr")
Downloading GitHub repo pbsag/tcadr@master
from URL https://api.github.com/repos/pbsag/tcadr/zipball/master
Installing tcadr
"C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD INSTALL  \
  "C:/Users/Greg/AppData/Local/Temp/Rtmpwvw2qc/devtools1814572d2483/pbsag-tcadr-8ae1a82"  \
  --library="\\Mac/Home/Documents/R/win-library/3.3" --install-tests 

* installing *source* package 'tcadr' ...
** libs
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.0/include" -DNDEBUG    -I"\\Mac/Home/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp:4:18: fatal error: Rcpp.h: No such file or directory
 #include <Rcpp.h>
                  ^
compilation terminated.
make: *** [RcppExports.o] Error 1
Warning: running command 'make -f "C:/PROGRA~1/R/R-33~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="tcadr.dll" WIN=64 TCLBIN=64 OBJECTS="RcppExports.o get_df_from_binary.o write_df_to_binary.o"' had status 2
ERROR: compilation failed for package 'tcadr'
* removing '\\Mac/Home/Documents/R/win-library/3.3/tcadr'
Error: Command failed (1)

克隆 repo 并在 Rstudio 中构建:

==> Rcmd.exe INSTALL --no-multiarch --with-keep.source tcadr

* installing to library '\\Mac/Home/Documents/R/win-library/3.3'
* installing *source* package 'tcadr' ...
** libs
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o tcadr.dll tmp.def RcppExports.o get_df_from_binary.o write_df_to_binary.o -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.0/bin/x64 -lR
C:\Rtools\mingw_64\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: get_df_from_binary.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: write_df_to_binary.o: File format not recognized
RcppExports.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'tcadr'
* removing '\\Mac/Home/Documents/R/win-library/3.3/tcadr'

Exited with status 1.

This question 有同样的错误,但这个接受的答案不适用,因为我的 git 存储库中没有任何已编译的目标文件。

请注意,我在 Windows 7 或 Mac 上的 3.2 中构建此包没有问题。


会话信息

R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_1.11.1

loaded via a namespace (and not attached):
[1] httr_1.1.0     R6_2.1.2       tools_3.3.0    withr_1.0.1    rstudioapi_0.5
[6] curl_0.9.7     memoise_1.0.0  git2r_0.15.0   digest_0.6.9 

【问题讨论】:

  • 我无法重现此错误,同样使用 Win 7 和 R 3.3.0。这里编译器工作正常,也使用 g++。也许你必须更新你的包,尤其是Rcpp
  • 我新安装的Rcpp

标签: r rcpp


【解决方案1】:

我最近不得不在 Windows 服务器上处理同样的问题。该问题与 Rtools 版本需要 v3.4 而不是 v3.3 才能与 R v3.3.0 一起使用有关。

此外,您需要从系统的PATH 变量中删除旧的 Rtools 路径重新安装之前!:

c:\Rtools\binc:\Rtools\gcc-4.x-y\bin

https://cran.r-project.org/bin/windows/Rtools/下载Rtools

编辑 1

默认情况下,它看起来像 Rtools 3.4。设置为在安装时包含这两个路径:

c:\Rtools\bin
c:\Rtools\mingw_32\bin

编辑 2

使用 RTools 的东西很少,你有:

  1. R toolset
  2. Cygwin DLLs
  3. R 3.3.x + 32 bit toolchain
  4. R 3.3.x + 64bit toolchain

确保以上所有内容均已勾选。

接下来,尝试自己安装包依赖:

install.packages(c("Rcpp","dplyr","data.table","testthat"))

从 GitHub 克隆存储库并打开项目文件后。尝试转到 RStudio 中的 Build 选项卡,然后选择 More -> Clean and Rebuild

【讨论】:

  • 好点,不过我有 Win 7、R 3.3.0 和 RTools 3.3,一切正常。但也许它是这个问题的解决方案。
  • 我正在使用 Rtools 3.4
  • Sys.getenv("PATH")
  • 另外,试试devtools::build_win()
  • 根据“R for Windows”常见问题解答 2.2,可能不要安装在带有空格的目录中。
【解决方案2】:

我在寻找解决方案的过程中做了一些事情,其中​​任何一个都可能奏效,但在鸡尾酒中,我现在已经安装并准备好了。

  1. 按照@dirkEddelbuettel 的建议,将 R 安装到 C:\R\R-3.3.0
  2. 使C:\R\R-3.3.0 可写,以便我可以将软件包安装到其内部库。
  3. 安装devtools的开发版本(你需要devtools来做这个:install.packages("devtools"); devtools::install_github("hadley/devtools")
  4. 安装两个 Rtools 的 32 位和 64 位版本,即使使用 64 位计算机也是如此。

【讨论】:

  • 最后一位是最重要的。 2 多年前我有过类似的经历:stackoverflow.com/questions/19885381/…
  • 另外,n.b. R 的 32 位和 64 位的 Windows Makeconf 具有硬编码的 C:\Rtools\ 路径,因此如果您安装到 C:\Rtools-3.4(就像我所做的那样),您会遇到构建错误,或者使用了出乎意料的旧 Rtools。
猜你喜欢
  • 2016-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-01
  • 1970-01-01
  • 2016-12-11
  • 2017-06-03
相关资源
最近更新 更多