R package with C/C++ and openMP: how to make "Makevars" file under "mypackage/src/" folder? -


i developing r package on mac osx low level c/c++ code , openmp support. c++ code written using rcpp package. global ''makevars'' file placed under ~/.r/ folder. file looks following.

cc=clang-omp cxx=clang-omp++  pkg_cflags=wall -pedantic pkg_cflags= -fopenmp pkg_cxxflags= -fopenmp pkg_libs= -fopenmp -lgomp 

everything works great under configuration!

however, want build package-specific makevars file own compilation make package portable. tried move global makevars file r pakcage src folder. however, compiler complained cannot find openmp header file omp.h:

** libs 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/bigmemory/include" -i"/library/frameworks/r.framework/versions/3.2/resources/library/bh/include"  -fopenmp -fpic  -wall -mtune=core2 -g -o2  -c rcppexports.cpp -o rcppexports.o rcppexports.cpp:12:10: fatal error: 'omp.h' file not found #include <omp.h>          ^ 1 error generated. make: *** [rcppexports.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/bigmemory/include" -i"/library/frameworks/r.framework/versions/3.2/resources/library/bh/include"  -fopenmp -fpic  -wall -mtune=core2 -g -o2  -c rcppexports.cpp -o rcppexports.o rcppexports.cpp:12:10: fatal error: 'omp.h' file not found #include <omp.h>          ^ 1 error generated. make: *** [rcppexports.o] error 1 

as can see, compilers become clang , clang++, not specified in makevars files: cc=clang-omp , cxx=clang-omp++.

question 1: how fix issue , build makevars file within r package?

another thing that, noticed writing r extensions that,

for example, package c code written openmp should have in src/makevars lines  pkg_cflags = $(shlib_openmp_cflags) pkg_libs = $(shlib_openmp_cflags) 

question 2: difference between, example, macro $(shlib_openmp_cflags) , flag -fopenmp? 1 under circumstance should use? tried replace flags macros, still cannot fix issue.

regarding question, favourite approach copy working packages. here eg part (recommended / core) package mgcv:

pkg_libs =  $(lapack_libs) $(blas_libs) $(flibs) $(shlib_openmp_cflags) pkg_cflags = $(shlib_openmp_cflags) 

i use same snippet in smaller winsorize package (on github) myself , andreas.

regarding question 2: first form more general , allow other openmp implementations. uses r found useable when configured.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -