gpt4 book ai didi

c++ - Rcpp Windows 编译失败

转载 作者:行者123 更新时间:2023-11-27 22:50:43 24 4
gpt4 key购买 nike

我开发了 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com