c++ - Rcpp Windows 编译失败

标签 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: 在 DESCRIPTION 中,但我不确定如何充分使用 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

最佳答案

问题由:

Syntax error: EOF in backquote substitution

因为一个

`

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.因为这是非常老派的(老式 Rcpp?)链接方式。

关于c++ - Rcpp Windows 编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37452530/

相关文章:

c++ - 在 VS2013 中构建 boost 库

linux - 使用gsrc编译glibc结果segment fault

c++ - qt :all classes inherit from QObject or delete Manually after new? 我应该采取什么方式

python - C++ 等价于 Python 的带有比较的数组访问 (array[condition] = value)

c++ - 在 Windows 上打印不工作

windows - 带有 Itemtemplate 或 IValueConverter 的 LongListSelector 的严重错误

c# - 如何在第一次打开应用程序时只启动一次页面?

windows - 到底是什么导致 Windows 中旋转的蓝色圆圈?

JavaFX:为什么无论我传递给 `changeListener`什么样的 `textArea.getKeyPressedProperty().addListener`都无法编译

C++ 问题...定义无法识别声明中指定的 vector