Rcpp Windows失败编译

时间:2016-05-26 05:46:21

标签: c++ windows compilation rcpp

我开发了Rcpp代码,它在Linux上编译,但我尝试了Windows。

我安装了Rtools,并设置了路径,路径显示正确。

> Sys.getenv("PATH")
[1] "C:\\Program Files\\R\\R-3.3.0\\bin\\x64;c:\\Rtools\\bin;c:\\Rtools\\gcc-4.6.3\\bin;c:\\MiKTeX\\miktex\\bin;c:\\Program Files\\R\\R-3.3.0\\bin\\;c:\\windows;c:\\windows\\system32;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32Files (x86)"

我安装了g ++

> system("g++ -v")
Using built-in specs.
COLLECT_GCC=c:\Rtools\GCC-46~1.3\bin\G__~1.EXE
COLLECT_LTO_WRAPPER=c:/rtools/gcc-46~1.3/bin/../libexec/gcc/i686-w64-mingw32/4.6.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /data/gannet/ripley/Sources/mingw-test3/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --prefix=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --with-    gmp=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpfr=/data/gannet/ripley/Sources/mingw
Thread model: win32
gcc version 4.6.3 20111208 (prerelease) (GCC) 

Make也由Rtools安装

> system("where make")
c:\Rtools\bin\make.exe



 system("R CMD INSTALL ./Sage_1.03.tar.gz")
* installing to library 'C:/Users/Melannies/Documents/R/win-library/3.3'
* installing *source* package 'Sage' ...
** libs
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.0/include" -DNDEBUG        -I"C:/Users/Melannies/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/Melannies/Documents/R/win-library/3.3/RcppArmadillo/include" -I"d:/Compiler/gcc-4.9.3/local330/include"  `-IC:/Users/Melannies/Documents/R/win-library/3.3/Rcpp/include   -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
Syntax error: EOF in backquote substitution
make: *** [RcppExports.o] Error 2
Warning: running command 'make -f "Makevars.win" -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="speedSage.dll" WIN=64 TCLBIN=64 OBJECTS="RcppExports.o aggregategsSumSigma.o bayesEstimation.o calcVIFarm_nosdalphaalt.o calcVIFarmalt.o notbayesEstimation.o sigmaArm.o sigmaSingle.o"' had status 2
ERROR: compilation failed for package 'Sage'
* removing 'C:/Users/Melannies/Documents/R/win-library/3.3/speedSage'
  Warning message:
running command 'R CMD INSTALL ./speedSage_1.03.tar.gz' had status 1 

所以我不知道错误RcppExports?我曾尝试订阅Rcpp-Devel,但遇到了麻烦。

这是Makevars.win

# Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")
PKG_CXXFLAGS=`$(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::CxxFlags()")

我确实有LinkingTo:在描述中,但我不确定如何完全使用LinkingTo

Package: Sage
Type: Package
Title: accelerated Client package 
Version: 1.04

Depends:
     Rcpp (>= 0.10.3),
     RcppArmadillo (>= 0.3.810.2),
     R (>= 2.15.0),
     stats,
     utils,
     arkas
Suggests: knitr,
      roxygen2
VignetteBuilder: knitr
Maintainer: anthony colombo <anthonycolombo60@gmail.com>
Description: Computes the necessary statistics for analysis using R 
License: GPL (>= 2)
LinkingTo: Rcpp, RcppArmadillo
RoxygenNote: 5.0.1
NeedsCompilation: yes

1 个答案:

答案 0 :(得分:4)

问题在于:

  

语法错误:反引号替换中的EOF

以来
`

位于Makevars.win

的最后一行的开头
PKG_CXXFLAGS=`$(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::CxxFlags()")

切换到:

PKG_CXXFLAGS=$(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::CxxFlags()")

你应该是金色的。

顺便说一句...... You should switch over the LinkingTo: feature of Rcpp.因为这是非常老派( vintage Rcpp?)的链接方式。