[Rcpp-devel] clang-omp and clang++ -fopenmp compiler (OS X)
gorillayue at gmail.com
Tue Apr 5 16:14:44 CEST 2016
I’m new to openmp and wonder if anyone know how to add -fopenmp to clang++ such that it can compile successfully without error using sourceCpp.
Using the dmvnorm_arma as example (http://gallery.rcpp.org/articles/dmvnorm_arma/ <http://gallery.rcpp.org/articles/dmvnorm_arma/>):
I got the following compiling error when do this:
dmvnrm_arma_mc.cpp:2:10: fatal error: 'omp.h' file not found
1 error generated.
make: *** [dmvnrm_arma_mc.o] Error 1
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/RcppArmadillo/include" -I"/Users/mike/Desktop" -fPIC -Wall -mtune=core2 -g -O2 -c dmvnrm_arma_mc.cpp -o dmvnrm_arma_mc.o
Error in Rcpp::sourceCpp("dmvnrm_arma_mc.cpp") :
Error 1 occurred building shared library.
After installing clang-omp, i can compile the ‘dmvnrm_arma_mc.cpp’ code without error using clang-omp compiler instead of clang++. But in order to use the compiled code in R environment, i still need to do the sourcing and linking like what sourceCpp automatically accomplishes.
So I wonder if it’s possible to either specify c++ compiler in sourceCpp or somehow add the ‘-fopenmp’ flag
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rcpp-devel