When I try to source a Rcpp file, I got the following error under macOS:
clang: error: unsupported option '-fopenmp'
After a little bit Googling, I found this post, which at the end solved my problem. Briefly, I did the following steps:
- Installed
xcodefrom Apple Store (a simplified version may be enough) or in Terminal withxcode-select --install - Installed
llvmviabrew install llvm - Downloaded and installed the
gfortranbinary installer from here. Note: You will need to download the OS X El Capitan gfortran 6.1 binaries regardless of whether or not you are on macOS Sierra, which presently only offers gfortran 6.3. - Downloaded and extracted
clangto/usr/local/clang(overwrite it if already exists,sudo cp -r ~/Downloads/usr/local/clang4 /usr/local/clang4). See here for more information. - In terminal
cat <<- EOF > ~/.R/Makevars
# The following statements are required to use the clang4 binary
CC=/usr/local/clang4/bin/clang
CXX=/usr/local/clang4/bin/clang++
LDFLAGS=-L/usr/local/clang4/lib
# End clang4 inclusion statements
EOF
Then, the error is fixed (for now)!