我正在尝试运行“无缝 R 和 C++ 与 Rcpp 集成”(第 32 页,清单 2.10)的代码,但它给出了一个错误。有人可以向我解释为什么不工作吗?谢谢
Code <- '
#include <gsL/gsl_const_mksa.h> // decl of constants
std::vector<double> volumes() {
std::vector<double> v(5);
v[0] = GSL_CONST_MKSA_US_GALLON; // 1 US gallon
v[1] = GSL_CONST_MKSA_CANADIAN_GALLON; // 1 Canadian gallon
v[2] = GSL_CONST_MKSA_UK_GALLON; // 1 UK gallon
v[3] = GSL_CONST_MKSA_QUART; // 1 quart
v[4] = GSL_CONST_MKSA_PINT; // 1 pint
return v;
}'
gslVolumes <- cppFunction(code, depends="RcppGSL")
这是消息错误:
file16e2b6cb966.cpp: In function ‘SEXPREC* sourceCpp_52966_volumes()’:
file16e2b6cb966.cpp:30: error: ‘__result’ was not declared in this scope
make: *** [file16e2b6cb966.o] Error 1
llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RcppGSL/include" -fPIC -mtune=core2 -g -O2 -c file16e2b6cb966.cpp -o file16e2b6cb966.o
Erro em sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.