R with C / C ++ and openMP: how to make the file "Makevars" in the folder "mypackage / src /"?

I am developing R package on Mac OSX with some low level code C/C++and openMP. The code is C++written using the package Rcpp. My global file "Makevars" is located in a folder ~/.R/. The file is as follows.

CC=clang-omp
CXX=clang-omp++

PKG_CFLAGS=Wall -pedantic
PKG_CFLAGS= -fopenmp
PKG_CXXFLAGS= -fopenmp
PKG_LIBS= -fopenmp -lgomp

Everything works fine in this configuration!

However, now I want to create a batch file Makevarsfor my own compilation in order to make the package portable. I tried to just move the global file Makevarsto the R pakcage folder src. However, the compiler complained that it could not find the 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

, clang clang++, , Makevars: CC=clang-omp CXX=clang-omp++.

1: , Makevars R?

, R-,

For example, a package with C code written for OpenMP should have in src/Makevars the lines

PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS)

2: , , $(SHLIB_OPENMP_CFLAGS) -fopenmp? ? , - .

+3
2

, - . , , (/) mgcv:

PKG_LIBS =  $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CFLAGS)
PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)

winsorize ( GitHub) .

2: OpenMP. , R , , .

+3

, Makevars, ; , ~/.R/Makevars C ++ OpenMP CC CXX.

( CRAN, Mac R, , Clang OpenMP), OpenMP, , , .

0

Source: https://habr.com/ru/post/1612243/


All Articles