1

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.

skatz
  • 115
  • 7

2 Answers2

2

For others troubleshooting a similar problem, what worked for me was to add these lines to the DESCRIPTION file of my R package:

LinkingTo:
    Rcpp,
    RcppArmadillo

Posting here in case it's helpful for others. I came across this solution here: https://mattstats.wordpress.com/2016/11/04/r-hub-for-microsoft-r-open/

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
gavin
  • 35
  • 5
0

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"

skatz
  • 115
  • 7