Rcpp:构建共享库时出错

时间:2014-06-27 13:11:26

标签: c++ rcpp

我在名为PSM.cpp的文件中有一个cpp代码,如下所示,

#include <Rcpp.h>

// [[Rcpp::export]]
std::vector<std::string> useInitLists() {
    std::vector<std::string> vec = {"larry", "curly", "moe"};
    return vec;
}

当我获取以下代码时,我收到以下错误。

> Rcpp::sourceCpp("PSM.cpp")
g++ -m64 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG     -I"C:/Users/30708/Documents/R/win-library/3.0/Rcpp/include"  -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall  -mtune=core2 -c PSM.cpp -o PSM.o
PSM.cpp: In function 'std::vector<std::basic_string<char> > useInitLists()':
PSM.cpp:5:60: error: in C++98 'vec' must be initialized by constructor, not by '{...}'
PSM.cpp:5:60: error: could not convert '{"larry", "curly", "moe"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
make: *** [PSM.o] Error 1
Error in Rcpp::sourceCpp("PSM.cpp") : 
  Error 1 occurred building shared library.

有人可以建议错误的含义以及如何解决错误吗?谢谢。

1 个答案:

答案 0 :(得分:1)

您可以使用替代-std=c++0x,但我从未在Windows上使用过g ++。

(很高兴它有帮助!)