无法从Mac编译包

问题描述 投票:0回答:1

我尝试在 R 中安装软件包,但收到以下错误:

clang: error: unsupported option '-fopenmp'

这是我收到错误后的结果:

ld: warning: search path '/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0' not found
ld: warning: search path '/opt/gfortran/lib' not found
ld: library 'gfortran' not found

根据我的理解,这是编译器的问题。所以我编辑了 .R/Makevars 以指向正确的编译器(GCC)。如果我理解正确的话,应该支持OpenMP。 这是目前我的 Makevars 文件:

# This file's location is ~/.R/Makevars
# Default variables (no omp)
# Also potentially CXX11 (for C++11 compiler)
# CXX11=/usr/bin/clang++

# I followed the instructions at http://hpc.sourceforge.net/ to install gcc 4.9
CC=/opt/homebrew/bin/gcc-14    
CXX=/opt/homebrew/bin/gcc-14
FC=/opt/homebrew/bin/gfortran
F77=/opt/homebrew/bin/gfortran

PKG_LIBS = -fopenmp -lgomp
PKG_CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp
CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp

SHLIB_OPENMP_CFLAGS=-Xpreprocessor -fopenmp
SHLIB_OPENMP_CXXFLAGS=-Xpreprocessor -fopenmp

我已经看到了有关该主题的其他一些问题,但它们要么与

data.table
包直接相关。或者他们没有解决问题。

r gcc compiler-errors package rcpp
1个回答
0
投票

对我有用的是直接设置编译器路径:

# This file's location is ~/.R/Makevars
# Default variables (no omp)

CC=/opt/homebrew/bin/gcc-14 
CXX=/opt/homebrew/bin/gcc-14 
FC=/opt/homebrew/bin/gfortran 
F77=/opt/homebrew/bin/gfortran 
FLIBS=-L/opt/homebrew/opt/gcc/lib/gcc/14  

不确定它是否支持 openMP,但它允许我编译该包。

© www.soinside.com 2019 - 2024. All rights reserved.