fatal error: 'RcppArmadillo.h' file not found

荒凉一梦 提交于 2021-01-29 16:43:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!