Automatically detects your Xcode version and installs the correct OpenMP runtime from the R CRAN macOS tools. Includes configuration testing and uninstall scripts.
install-openmp.sh
: Main installer with auto-detectioncheck-openmp.sh
: Compilation and configuration checkeruninstall-openmp.sh
: Clean removal of OpenMP files
- macOS 10.13+ (High Sierra) or macOS 11+ (Big Sur) for Apple Silicon
- Xcode Command Line Tools (
xcode-select --install
) - Admin privileges for installation
# Download and run installer
curl -O https://raw.githubusercontent.com/coatless-shell/openmp/main/install-openmp.sh
chmod +x install-openmp.sh
./install-openmp.sh
# Check your installation
curl -O https://raw.githubusercontent.com/coatless-shell/openmp/main/check-openmp.sh
chmod +x check-openmp.sh
./check-openmp.sh
# Uninstall if needed
curl -O https://raw.githubusercontent.com/coatless-shell/openmp/main/uninstall-openmp.sh
chmod +x uninstall-openmp.sh
./uninstall-openmp.sh
Xcode Version | Apple Clang | OpenMP Version | Download |
---|---|---|---|
16.3+ | 1700.x | 19.1.0 | openmp-19.1.0-darwin20-Release.tar.gz |
16.0-16.2 | 1600.x | 17.0.6 | openmp-17.0.6-darwin20-Release.tar.gz |
15.x | 1500.x | 16.0.4 | openmp-16.0.4-darwin20-Release.tar.gz |
14.3.x | 1403.x | 15.0.7 | openmp-15.0.7-darwin20-Release.tar.gz |
14.0-14.2 | 1400.x | 14.0.6 | openmp-14.0.6-darwin20-Release.tar.gz |
13.3-13.4.1 | 1316.x | 13.0.0 | openmp-13.0.0-darwin21-Release.tar.gz |
13.0-13.2.1 | 1300.x | 12.0.1 | openmp-12.0.1-darwin20-Release.tar.gz |
12.5 | 1205.x | 11.0.1 | openmp-11.0.1-darwin20-Release.tar.gz |
12.0-12.4 | 1200.x | 10.0.0 | openmp-10.0.0-darwin17-Release.tar.gz |
11.4-11.7 | 1103.x | 9.0.1 | openmp-9.0.1-darwin17-Release.tar.gz |
11.0-11.3.1 | 1100.x | 8.0.1 | openmp-8.0.1-darwin17-Release.tar.gz |
10.2-10.3 | 1001.x | 7.1.0 | openmp-7.1.0-darwin17-Release.tar.gz |
Note
- OpenMP 11.0.1 and above include both Intel (x86_64) and Apple Silicon (arm64) support and require macOS 11+.
- OpenMP 10.0.0 and below require macOS 10.13+ and are Intel-only.
To place OpenMP headers on macOS for use with Apple's Xcode toolchain, please use:
# Download and run installer
curl -O https://raw.githubusercontent.com/coatless-shell/openmp/main/install-openmp.sh
chmod +x install-openmp.sh
./install-openmp.sh
Important
You will be prompted for your user account password to install files.
Add to ~/.R/Makevars
for system-wide OpenMP support:
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp
Note
Once set, it will be applied universally across any package installations or local script compilations.
Use when you prefer session-specific control or don't want permanent system changes:
Sys.setenv(PKG_CPPFLAGS = '-Xclang -fopenmp')
Sys.setenv(PKG_LIBS = '-lomp')
install.packages('myPackage', type = 'source')
For one-off package installations:
PKG_CPPFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL myPackage
Having difficulties or are unsure if you have OpenMP installed correctly? Use:
# Download check script
curl -O https://raw.githubusercontent.com/coatless-shell/openmp/main/check-openmp.sh
chmod +x check-openmp.sh
# Check your installation
./check-openmp.sh
Note
Not interested in R? No worries, you can safely skip those tests with --disable-r
!
# C/C++ only tests (no R)
./check-openmp.sh --disable-r
The check-openmp.sh
script provides verification of your OpenMP setup with 5 test categories:
- Installation Check: Verifies library and header files
- Compiler Verification: Confirms clang is available and working
- Compilation Testing: Tests OpenMP compilation and execution
- R Configuration: Checks
~/.R/Makevars
setup - Environment Variables: Validates R session variables (only if Makevars not configured)
The checker uses smart logic:
- R-specific tests are skipped if
--disable-r
is passed, e.g.- Skip 4. R Configuration and 5. Environment Variables checks.
- If
~/.R/Makevars
is properly configured, it skips 5. Environment Variables testing.- Otherwise, it queries R directly to check session-specific settings using
Sys.getenv()
.
- Otherwise, it queries R directly to check session-specific settings using
To remove OpenMP:
curl -O https://raw.githubusercontent.com/coatless-shell/openmp/main/uninstall-openmp.sh
chmod +x uninstall-openmp.sh
./uninstall-openmp.sh
Important
You will be prompted for your user account password to delete files.
First, run the checker: ./check-openmp.sh
provides detailed diagnostics and specific fix instructions for any issues.
Common issues and solutions:
- "Unsupported clang version": Your Xcode version isn't supported. Check mac.r-project.org/openmp for updates
- "Library not found": OpenMP isn't installed. Run
./install-openmp.sh
- "Checksum verification failed": Download was corrupted. Try running the installer again or check your network connection
- "Compilation failed": Check that Xcode Command Line Tools are installed (
sudo xcode-select --install
) - "No parallelization": Verify configuration in
~/.R/Makevars
or R environment variables - "R not found": Either install R or use
--disable-r
flag for C/C++ only testing
Consider using the {macrtools}
R package to setup the development toolchain directly from R.
AGPL (>= 3)