I am trying to use openmp in my Rcpp code and encounter some issues (Mac OS). Have tried googling a lot but not able to find a solution that works for me. Would appreciate if you can provide some thoughts.
Some of my setups: 1) installed llvm from home-brew 2) Makevars in ~/.R
CXX= /usr/local/opt/llvm/bin/clang-cpp
CXXFLAGS =-I/usr/local/lib -I/usr/local/opt/llvm/include
LDFLAGS=β-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/libβ
It looks like the LDFLAGS specified in the Makevars was ignored. Also, when I use sourceCpp(temp.cpp), I get this error
usr/local/opt/llvm/bin/clang-cpp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Users/myname/Library/R/3.2/library/Rcpp/include" -I"/Users/myname/Library/R/3.2/library/RcppArmadillo/include" -fopenmp -fPIC -I/usr/local/lib -I/usr/local/opt/llvm/include -c temp.cpp -o temp.o
In file included from temp.cpp:2: /usr/local/Cellar/llvm/4.0.0_1/bin/../include/c++/v1/math.h:301:15: fatal error: 'math.h' file not found
include_next
^~~~~~~~ 1 error generated. Error in sourceCpp(paste(path2, "temp.cpp", sep = ""), verbose = TRUE, :
Error 1 occurred building shared library. make: *** [temp.o] Error 1
In the temp.cpp, I have put
#include <math.h>
#include <RcppArmadillo.h>
#include <omp.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::plugins(openmp)]]
using namespace Rcpp;