Efforts on resolving compiling issues upon installing R packages on the Mac M1 chip

https://mac.r-project.org/openmp/#do

https://github.com/Rdatatable/data.table/wiki/Installation

1. Install Xcode or Command Line Tool

Run the following from Terminal:

xcode-select --install

If you get an error message: xcode-select: error: command line tools are already installed, use "Software Update" to install updates, then you already have command line tools and can proceed to the next step. Else please follow the onscreen instructions and install it first.

2. Add the OpenMP runtime for clang

2.1 install libomp

Install homebrew if you have not already. Run the following from Terminal:

brew update && brew install libomp

2.2 OpenMP run-time downloads

Run the following from the Terminal:

curl -O https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
sudo tar fvxz openmp-12.0.1-darwin20-Release.tar.gz -C /

3. Enable OpenMP

3.1 Download the libomp run-time corresponding to the Xcode version you use from the links above (Step1, 2 above)

Normally, you should find the following files:

    usr/local/lib/libomp.dylib
    usr/local/include/ompt.h
    usr/local/include/omp.h
    usr/local/include/omp-tools.h

3.2 Add -Xclang -fopenmp to CPPFLAGS, add -lomp to LIBS

Add the following contents into you home directory ~/.R/Makevars with your preferred text editor (create this file if you don’t have):

CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp

Note that the file is hidden by default, using shift+cmd+. to show hidden files. Be very careful when doing this, always check your ~/.R/Makevars whenever you upgrade R, macOS or Xcode.

4. Verifying code signatures (optional)

Normally, it should be work here. You may want to verify the signatures via code tools. Run the following from Terminal:

codesign -d -vv /usr/local/lib/libomp.dylib

Then you should see the output like this:

$ codesign -d -vv /usr/local/lib/libomp.dylib 
Executable=/usr/local/lib/libomp.dylib
Identifier=libomp
Format=Mach-O universal (x86_64 arm64)
CodeDirectory v=20400 size=5514 flags=0x0(none) hashes=167+2 location=embedded
Signature size=8927
Authority=Developer ID Application: Simon Urbanek (VZLD955F6P)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=11/11/2021 at 1:29:04 PM
Info.plist=not bound
TeamIdentifier=VZLD955F6P
Sealed Resources=none
Internal requirements count=1 size=168

5. Testing

Try to install packages to see if you succeed, for example:

install.packages(c("Rcpp", "data.table"), type = "source")

原文地址:http://www.cnblogs.com/res-daqian-lu/p/16849483.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性