Skip to content

Instantly share code, notes, and snippets.

@christianrickert
Last active October 23, 2022 22:56
Show Gist options
  • Save christianrickert/8c1634a7f749589ff915368f66869aa1 to your computer and use it in GitHub Desktop.
Save christianrickert/8c1634a7f749589ff915368f66869aa1 to your computer and use it in GitHub Desktop.
Install 'data.table' R package with OpenMP on MacOS
## R expects this file to be in its hidden config folder
# mkdir ~/.R
# touch ~/.R/Makevars
## Install 'OpenMP' using Homebrew in Terminal
# brew update && brew install libomp
## Include 'OpenMP' library with clang
HOMEBREW_PATH=/opt/homebrew
# 'openmp' was symlinked (package)
CPPFLAGS += -I$(HOMEBREW_PATH)/include
LDFLAGS += -L$(HOMEBREW_PATH)/lib
# 'openmp' wasn't symlinked (keg-only)
CPPFLAGS += -I$(HOMEBREW_PATH)/opt/libomp/include
LDFLAGS += -L$(HOMEBREW_PATH)/opt/libomp/lib
## Enable 'OpenMP' library with clang
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp
## Install these packages to avoid compilation errors
# brew install xquartz
# brew install tcl-tk
## Install 'data.table' with R console
# remove.packages("data.table")
# install.packages("data.table", type = "source")
## Load 'data.table' with R console and test
# library("data.table")
# test.data.table()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment