1

I tried to build a package that has RcppArmadillo codes, but always had encountered compilation errors. To be simple, I started without adding my own codes. I firs tried

library(Rcpp)
Rcpp.package.skeleton("test")

I run "R CMD check test", and no errors returned. I then did the same thing for RcppArmadillo command as follows:

library(Rcpp)
Rcpp.package.skeleton("test1")

When I run "R CMD check test1" from command line, then I got an error message as follows:

...
* checking whether package ‘test1’ can be installed ... ERROR
Installation failed. 
...

I further checked the 00install.out file, it says

clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppArmadillo/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fopenmp  -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang: error: unsupported option '-fopenmp'
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘test1’

Anyone has any idea on "error: unsupported option '-fopenmp' make"? how to fix it?

Thanks in advance!

Update: I followed the instruction from website and did the following: 1. update xcode 2. brew install llvm 3. download gcc and clang 8 from cran and installed 4. created ~/R directory and created a file Makevars as follows:

  # The following statements are required to use the clang8 binary
  CC=/usr/local/clang8/bin/clang
  CXX=/usr/local/clang8/bin/clang++
  CXX11=$CXX
  CXX14=$CXX
  CXX17=$CXX
  CXX1X=$CXX
  LDFLAGS=-L/usr/local/clang8/lib
  # End clang8 inclusion statements
  1. I created test1 package (again without adding my R codes or RcppArmadillo codes). Run R CMD check test1. The Clang error is gone, but I got the new errors:
/bin/sh: XX: command not found
make: *** [RcppExports.o] Error 127

Any help on the new error? what is it? thanks!

  • I would read [this excellent guide](https://thecoatlessprofessor.com/programming/cpp/openmp-in-r-on-os-x/) to dealing with OpenMP issues on Mac. This is also probably a duplicate – duckmayr Oct 04 '19 at 12:10
  • thanks for help. I followed instructions, and the Clang error now is gone. But I got new errors which I have no idea. – Ji-Ping Wang Oct 04 '19 at 15:46
  • Try explicitly setting them per the answer here: https://stackoverflow.com/a/51757427/8386140 That is, change `CXX11=$CXX` etc. to `CXX=/usr/local/clang8/bin/clang++` etc. – duckmayr Oct 04 '19 at 15:49
  • @duckmayr, thanks so much! You pinpointed it. It works now after revising the Makevars file as you advised. – Ji-Ping Wang Oct 04 '19 at 16:09

0 Answers0