问题
Rcpp::sourceCpp('~/Desktop/my.cpp')
Was working on some stand alone Rcpparmadillo files and came across this error:
fatal error: 'RcppArmadillo.h' file not found
#include <RcppArmadillo.h>
^~~~~~~~~~~~~~~~~
The example "my.cpp":
// [[Rcpp::depends(RcppArmadillo)]
#include <RcppArmadillo.h>
// [[Rcpp::export]]
arma::vec add_two(arma::vec x){
return x + 2;
}
/*** R
add_two( c(42, 22))
*/
I recently upgraded to RcppArmadillo version 0.9.900.1.0 and I am on macOS Catalina 10.15.5 and R version 3.6.1. This seems unusual as I can still build a package with RcppArmadillo, anyway I found some solution I will post below incase someone else has the same problem.
回答1:
Copied contents of the folder:
-I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppArmadillo/include"
To:
-I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include"
来源:https://stackoverflow.com/questions/62355398/fatal-error-rcpparmadillo-h-file-not-found