在macOS上安装data.table [英] installing data.table on macOS
问题描述
我需要在macOS 11.1上安装data.table 1.12.0(特别是).
I need to install data.table 1.12.0 (specifically) on macOS 11.1.
我遇到错误:
clang: error: unsupported option '-fopenmp'
make: *** [assign.o] Error 1
我已按照 https中的说明进行操作://github.com/Rdatatable/data.table/wiki/Installation#openmp-enabled-compiler-for-mac ,但仍无法使其正常工作.R 3.6.1.
I have followed the directions in https://github.com/Rdatatable/data.table/wiki/Installation#openmp-enabled-compiler-for-mac but still unable to get it to work. R 3.6.1.
我还尝试了R CMD安装,并得到了相同的错误:
I also tried a R CMD install and got the same error:
R CMD install data.table_1.12.0.tar.gz
* installing to library ‘/Users/XXX/Library/R/3.6/library’
* installing *source* package ‘data.table’ ...
** package ‘data.table’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fopenmp -fPIC -Wall -g -O2 -c assign.c -o assign.o
clang: error: unsupported option '-fopenmp'
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Users/XXX/Library/R/3.6/library/data.table’
更新:对我来说,从CRAN安装最新的data.table似乎也是一个问题,因此显然它不限于1.12.0.
Update: Seems to be an issue install latest data.table from CRAN for me as well, so its not restricted to 1.12.0 apparently.
推荐答案
此问题特定于Big Sur;这些是我用来解决问题的步骤(每个 https://stackoverflow.com/a/65334247/12957340 ):
This issue is specific to Big Sur; these are the steps I used to solve the problem (per https://stackoverflow.com/a/65334247/12957340):
- 重新安装xcode命令行工具(即使其显示最新")
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
- 安装gcc&通过Homebrew(安装Homebrew的说明的llvm),或者,如果您已经通过Homebrew安装了gcc/llvm,跳到下一步
- Install gcc & llvm via Homebrew (instructions for installing Homebrew) or, if you already have gcc/llvm installed via Homebrew, skip to the next step
# This can take several hours
brew install gcc
brew install llvm
- 一旦您有gcc&通过Homebrew安装的llvm:
brew cleanup
brew update
brew upgrade
brew reinstall gcc
brew reinstall llvm
- 将一些标题链接到/usr/local/include
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
# You can safely ignore warnings like this:
#ln: /usr/local/include//tcl.h: File exists
#ln: /usr/local/include//tclDecls.h: File exists
#ln: /usr/local/include//tclPlatDecls.h: File exists
#ln: /usr/local/include//tclTomMath.h: File exists
#ln: /usr/local/include//tclTomMathDecls.h: File exists
#ln: /usr/local/include//tk.h: File exists
#ln: /usr/local/include//tkDecls.h: File exists
#ln: /usr/local/include//tkPlatDecls.h: File exists
- 创建一个新的
〜/.R/Makevars
文件(如果您已经有一个〜/.R/Makevars
文件,请将其保存在其他目录中(远离〜/.R/
)),并且仅在文件中包含以下几行:
- Create a new
~/.R/Makevars
file (if you already have a~/.R/Makevars
file, save it in a different directory (away from~/.R/
)) and include only these lines in the file:
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++
LLVM_LOC = /usr/local/opt/llvm
CC=/usr/local/gfortran/bin/gcc -fopenmp
CXX=/usr/local/gfortran/bin/g++ -fopenmp
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
- 从R/Rstudio中的源代码编译data.table
install.packages("data.table", type = "source")
# To check whether it installed correctly, run:
library(data.table)
- 如果您的软件包无法编译,则几个SO用户必须安装新的gfortran(re: https://stackoverflow.com/a/65334247/12957340 ),您可以从 https://github.com/fxcoudert/gfortran-for-macOS/releases/tag/10.2-bigsur-intel
- If your package fails to compile, a couple of SO users have had to install a fresh gfortran (re: https://stackoverflow.com/a/65334247/12957340), which you can download from https://github.com/fxcoudert/gfortran-for-macOS/releases/tag/10.2-bigsur-intel
这篇关于在macOS上安装data.table的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!