Installing R on OSX Big Sur (EDIT: and Apple M1) for use with Rcpp and openMP
Eventually, I found a process that works on a M1 mac with Big Sur.
- Head over to https://mac.r-project.org/, it contains most things you will need
- Download and install R via
R-4.1-branch.pkg
. The CRAN version might also work, but I used the installer from mac.r-project.org, which required opening the osx security settings to allow the installation. - Install RStudio, start it, and let it install the developer tools. Alternatively, run
sudo xcode-select --install
in Terminal. - Head to https://mac.r-project.org/openmp/. Download
openmp-11.0.1-darwin20-Release.tar.gz
and install it (see Terminal commands below).
curl -O https://mac.r-project.org/openmp/openmp-11.0.1-darwin20-Release.tar.gz
sudo tar fvx openmp-11.0.1-darwin20-Release.tar.gz -C /
- Now we need to add compiler flags so that clan uses openMP. In Terminal, create the
Makevars
file.
cd ~
mkdir .R
nano .R/Makevars
in nano, paste these additional compiler flags into the Makevars
file:
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp
Hit Control+O, Control+X to save and close
- Head over to the gfortran page: https://github.com/fxcoudert/gfortran-for-macOS/releases
- Use the installer
gfortran-ARM-11.0-BigSur.pkg
to install gfortran. - For some reason it appears to install in
/usr/local/gfortran
, but R expects it in/opt
. The mac-R team likes to separate arm64 and intel related files. We could go and fix paths, or simply also install gfortran under/opt
. Download the tar filegfortran-ARM-11.0-BigSur.tar.xz
. You can use curl, or just download it and point tar in the command line to it.
cd /opt/R/arm64/
sudo mkdir gfortran
sudo tar -xzyf gfortran-ARM-11.0-BigSur.tar.xz -C /opt/R/arm64/
(replace gfortran-ARM-11.0-BigSur.tar.xz
with /users/YOURUSERNAME/downloads/gfortran-ARM-11.0-BigSur.tar.xz
)
Now it should work.
Not an expert in OSX, but doing this so others can figure out how to use my R package. I'd like to streamline the process some more, but wiping the mac, reinstalling osx and testing it takes so much time.
R - can I stop the rattle package from starting up X11 on Mac OS X 10.11 (El Capitan)
rattle needs XQuartz in order to run. It uses GTK to draw the windows which in turn uses X11/XQuartz.
Related Topics
How to Add Gaussian Curve to Histogram Created with Qplot
Linear Model with 'Lm': How to Get Prediction Variance of Sum of Predicted Values
Simple R 3D Interpolation/Surface Plot
Using Pivot_Longer with Multiple Paired Columns in the Wide Dataset
Create Link to the Other Part of the Shiny App
Constructing a Named List Without Having to Type Each Object's Name Twice
R: Saving Ggplot2 Plots in a List
Flexdashboard - Change Title Bar Color
R Histogram with Multiple Populations
Extracting Zip+CSV File from Attachment W/ Image in Body of Email
Remove Duplicate Rows from Xts Object
Wavelet Reconstruction of Time Series
R Error: Unknown Timezone with As.Posixct()
Generate a Sequence of Numbers with Repeated Intervals
Marginal Effects of Mlogit in R
Running Out of Heap Space in Sparklyr, But Have Plenty of Memory