R语言inline包 cxxfunction函数

栗子

library(inline)

inc <- '
using namespace Rcpp;

double norm( double x, double y ) {
  return sqrt( x*x + y*y );
}

RCPP_MODULE(mod) {
  function( "norm", &norm );
}'


fx <- cxxfunction(signature(), plugin="Rcpp", include=inc)

报错

> fx <- cxxfunction(signature(), plugin="Rcpp", include=inc)
Warning message:
运行命令'make -f "D:/develop/R/R-34~1.0/etc/x64/Makeconf" -f "D:/develop/R/R-34~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file3cac170f3473.dll" WIN=64 TCLBIN=64 OBJECTS="file3cac170f3473.o"'的状态是127 

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: 
  2: // includes from the plugin
  3: 
  4: #include <Rcpp.h>
  5: 
  6: 
  7: #ifndef BEGIN_RCPP
  8: #define BEGIN_RCPP
  9: #endif
 10: 
 11: #ifndef END_RCPP
 12: #define END_RCPP
 13: #endif
 14: 
 15: using namespace Rcpp;
 16: 
 17: 
 18: // user includes
 19: 
 20: using namespace Rcpp;
 21: 
 22: double norm( double x, double y ) {
 23:   return sqrt( x*x + y*y );
 24: }
 25: 
 26: RCPP_MODULE(mod) {
 27:   function( "norm", &norm );
 28: }
 29: 
 30: // declarations
 31: extern "C" {
 32: SEXP file3cac170f3473( ) ;
 33: }
 34: 
 35: // definition
 36: 
 37: SEXP file3cac170f3473(  ){
 38: BEGIN_RCPP
 39: 
 40: END_RCPP
 41: }
 42: 
 43: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Warning message:
运行命令'make -f "D:/develop/R/R-34~1.0/etc/x64/Makeconf" -f "D:/develop/R/R-34~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file3cac170f3473.dll" WIN=64 TCLBIN=64 OBJECTS="file3cac170f3473.o"'的状态是127 
In addition: Warning message:
running command 'D:/develop/R/R-34~1.0/bin/x64/R CMD SHLIB file3cac170f3473.cpp 2> file3cac170f3473.cpp.err.txt' had status 1 

只要我一用cxxfunction函数就会报错

阅读 3.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进