[Rcpp-devel] clang-omp and clang++ -fopenmp compiler (OS X)

Qiang Kou qkou at umail.iu.edu
Tue Apr 5 16:24:56 CEST 2016


Hi, Li,

Please create the file "~/.R/Makevars" and put the following content in it

CC=clang-omp
CXX=clang-omp++
CFLAGS += -O3 -Wall -pipe -pedantic
CXXFLAGS += -O3 -Wall -pipe -Wno-unused -pedantic -fopenmp

You can add or change flags in this file.

Best,

KK

On Tue, Apr 5, 2016 at 10:14 AM, Yue Li <gorillayue at gmail.com> wrote:

> Dear List,
>
> 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/):
>
> I got the following compiling error when do this:
>
> > Rcpp::sourceCpp('dmvnrm_arma_mc.cpp')
> *dmvnrm_arma_mc.cpp:2:10: **fatal error: **'omp.h' file not found*
> #include <omp.h>
> *         ^*
> 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,
> Yue
>
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>



-- 
Qiang Kou
qkou at umail.iu.edu
School of Informatics and Computing, Indiana University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20160405/431ee6db/attachment.html>


More information about the Rcpp-devel mailing list