Fatal error for

前端 未结 2 1091
被撕碎了的回忆
被撕碎了的回忆 2021-01-26 16:39

I am running this example, through terminal. But got fatal error: RInside.h: No such file or directory error for the the line, #include

2条回答
  •  生来不讨喜
    2021-01-26 17:18

    You should specify the path of header file when compiling RInside with g++. There is a parameters list of g++ on Mac OS X (10.14.2 Mojave) for your reference, hope this help.

    g++ 
    -I/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RInside/include \
    -I/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include \
    -I/Library/Frameworks/R.framework/Versions/3.5/Resources/include \
    -L/Library/Frameworks/R.framework/Versions/3.5/Resources/lib \
    -L/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RInside/lib \
    -lR -lRInside -O3 -o test helloworld_rinside.cpp
    

    source code of "helloworld_rinside.cpp", http://dirk.eddelbuettel.com/code/rinside.html

    // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4;  tab-width: 8; -*-
    //
    // Simple example showing how to do the standard 'hello, world' using embedded R
    //
    // Copyright (C) 2009 Dirk Eddelbuettel
    // Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
    //
    // GPL'ed
    
    #include  // for the embedded R via RInside
    
    int main(int argc, char *argv[]) {
    
      RInside R(argc, argv); // create an embedded R instance
    
      R["txt"] = "Hello, world!\n"; // assign a char* (string) to 'txt'
    
      R.parseEvalQ("cat(txt)"); // eval the init string, ignoring any returns
    
      exit(0);
    }
    

提交回复
热议问题