在Windows上使用用户定义的头文件编译Rcpp程序时出现问题

在Windows上使用用户定义的头文件编译Rcpp程序时出现问题,r,windows,rcpp,R,Windows,Rcpp,1。问题 我试图编译一个带有用户定义的.hpp头文件的Rcpp程序,其示例见第2.10.2节第9页。它在我的Mac电脑上的RStudio中编译得很好,运行良好 但是,当我在Windows 64位笔记本电脑(Win 7)上运行完全相同的程序时,我会收到以下错误消息: g++ -m64 -I"G:/R-32~1.3/include" -DNDEBUG -I"G:/R-3.2.3/library/Rcpp/include" -I"F:/_tst/rcpp" -I"d:/RCompile/r-

1。问题

我试图编译一个带有用户定义的.hpp头文件的Rcpp程序,其示例见第2.10.2节第9页。它在我的Mac电脑上的RStudio中编译得很好,运行良好

但是,当我在Windows 64位笔记本电脑(Win 7)上运行完全相同的程序时,我会收到以下错误消息:

g++ -m64 -I"G:/R-32~1.3/include" -DNDEBUG     -I"G:/R-3.2.3/library/Rcpp/include" -I"F:/_tst/rcpp"  -I"d:/RCompile/r-compiling/local/local323/include"     -O2 -Wall  -mtune=core2 -c tst4.cpp -o tst4.o
G:\Rtools\gcc-4.6.3\bin\nm.exe: 'F:_tstrcpputilities.o': No such file
g++ -m64 -shared -s -static-libgcc -o sourceCpp_1.dll tmp.def F:_tstrcpputilities.o tst4.o -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LG:/R-32~1.3/bin/x64 -lR
g++.exe: error: F:_tstrcpputilities.o: No such file or directory
Error in sourceCpp("tst4.cpp") : Error occurred building shared library. 
似乎文件路径中的斜杠丢失了(我假设不是
'F:\u tstrcpputilities.o'
,而是
'F:\\u tst\rcpp\utilities.o'
?),但我不知道如何修复此问题

2。暂定解决方案,但未成功

我尝试使用
devtool
将我的Rtools和Rtools/gcc-x.x.x/bin目录添加到PATH,如下所示:

add_path("G:\\Rtools");
add_path("G:\\Rtools\\bin");
add_path("G:\\Rtools\\gcc-4.6.3\\bin");
不幸的是,这没有帮助。同样的错误依然存在

所以…

我被困在这里了。。。任何帮助都将不胜感激

=========================================================================

S1。补充信息

关于我的笔记本电脑/R/R工具的一些信息:

  • OS:WIN7 64位
  • R版本:3.2.3(2015-12-10)-“木制圣诞树”
  • Rtools版本:Rtools3.3
我使用的测试cpp代码(文件名:tst4.cpp)是:

#include <Rcpp.h>
#include "utilities.hpp"

using namespace Rcpp;

// [[Rcpp::export]]
double timesTwenty(double x) {
    return timesTwo(x) * 10;
}
#包括
#包括“utilities.hpp”
使用名称空间Rcpp;
//[[Rcpp::导出]]
双倍二十(双倍x){
返回时间2(x)*10;
}

所有.cpp和.hpp文件都在同一个文件夹中。

只不过是打了个喷嚏,但可能是路径名中的前导下划线导致了某些错误?尝试使用文件夹,例如
F:\test
而不是
F:\\u test
@KevinUshey谢谢你的建议。我尝试使用
F:\test
,但它仍然给我同样的错误=(只是胡说八道,但可能是路径名中的前导下划线导致出现错误?请尝试使用文件夹,例如
F:\test
,而不是
F:\\u test
@KevinUshey谢谢你的建议。我尝试使用
F:\test
,但仍然会出现相同的错误。)=(