在 M1 mac 上安装 R 包 "nloptr" 时出现问题
Problems installing R package "nloptr" on M1 mac
我正在尝试在 R 和 RStudio 中安装“lme4”库,它在我使用 M1 Mac 之前可以正常工作,但现在无法安装。有问题的依赖是:“nloptr”。这是我当前的错误:
clang++ -arch arm64 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm -Lnlopt/lib -lnlopt -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-Lnlopt/lib'
ld: library not found for -lnlopt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/ht/y6qd6yfn67x086jtwxvh42tw0000gn/T/RtmpULtpZq/downloaded_packages’ ```
我在蒙特雷 (12.1) 的 M1 Mac 上。我已经安装了 R 的 arm64 版本。这是我当前的版本 R 4.1.2:
> version
_
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 1.2
year 2021
month 11
day 01
svn rev 81115
language R
version.string R version 4.1.2 (2021-11-01)
nickname Bird Hippie
我已经在终端中尝试了以下操作:brew install nlopt
和 brew install gcc
。
在此之前,我也报错如下:
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0'
为了解决这个问题,基于谷歌搜索,我这样做了
export PATH=$PATH:/opt/R/arm64/gfortran/bin
还有这个
ln -sfn `xcrun --show-sdk-path` /opt/R/arm64/gfortran/SDK
在我的机器上(M1 Mac 运行 Big Sur),我刚刚尝试 install.packages("nloptr")
没有 先做 brew install nlopt
.
我收到关于 -Lnlopt/lib
的相同警告:
ld: warning: directory not found for option '-Lnlopt/lib'
ld: library not found for -lnlopt
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
但在警告之前我看到:
checking if pkg-config knows NLopt... no
using NLopt via local cmake build on arm64
------------------ CMAKE NOT FOUND --------------------
CMake was not found on the PATH. Please install CMake:
- yum install cmake (Fedora/CentOS; inside a terminal)
- apt install cmake (Debian/Ubuntu; inside a terminal).
- pacman -S cmake (Arch Linux; inside a terminal).
- brew install cmake (MacOS; inside a terminal with Homebrew)
- port install cmake (MacOS; inside a terminal with MacPorts)
Alternatively install CMake from: <https://cmake.org/>
-------------------------------------------------------
install.packages("nloptr")
在我使用 brew install cmake
.
安装 CMake 后成功
关于 gfortran
的最初问题,我可能建议您尝试我的说明 。 R 建议安装 gfortran
的特定版本并配置编译器以通过 ~/.R/Makevars
找到该安装。你真的不需要弄乱你的 PATH
...
我正在尝试在 R 和 RStudio 中安装“lme4”库,它在我使用 M1 Mac 之前可以正常工作,但现在无法安装。有问题的依赖是:“nloptr”。这是我当前的错误:
clang++ -arch arm64 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm -Lnlopt/lib -lnlopt -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-Lnlopt/lib'
ld: library not found for -lnlopt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/ht/y6qd6yfn67x086jtwxvh42tw0000gn/T/RtmpULtpZq/downloaded_packages’ ```
我在蒙特雷 (12.1) 的 M1 Mac 上。我已经安装了 R 的 arm64 版本。这是我当前的版本 R 4.1.2:
> version
_
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 1.2
year 2021
month 11
day 01
svn rev 81115
language R
version.string R version 4.1.2 (2021-11-01)
nickname Bird Hippie
我已经在终端中尝试了以下操作:brew install nlopt
和 brew install gcc
。
在此之前,我也报错如下:
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0'
为了解决这个问题,基于谷歌搜索,我这样做了
export PATH=$PATH:/opt/R/arm64/gfortran/bin
还有这个
ln -sfn `xcrun --show-sdk-path` /opt/R/arm64/gfortran/SDK
在我的机器上(M1 Mac 运行 Big Sur),我刚刚尝试 install.packages("nloptr")
没有 先做 brew install nlopt
.
我收到关于 -Lnlopt/lib
的相同警告:
ld: warning: directory not found for option '-Lnlopt/lib'
ld: library not found for -lnlopt
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
但在警告之前我看到:
checking if pkg-config knows NLopt... no
using NLopt via local cmake build on arm64
------------------ CMAKE NOT FOUND --------------------
CMake was not found on the PATH. Please install CMake:
- yum install cmake (Fedora/CentOS; inside a terminal)
- apt install cmake (Debian/Ubuntu; inside a terminal).
- pacman -S cmake (Arch Linux; inside a terminal).
- brew install cmake (MacOS; inside a terminal with Homebrew)
- port install cmake (MacOS; inside a terminal with MacPorts)
Alternatively install CMake from: <https://cmake.org/>
-------------------------------------------------------
install.packages("nloptr")
在我使用 brew install cmake
.
关于 gfortran
的最初问题,我可能建议您尝试我的说明 gfortran
的特定版本并配置编译器以通过 ~/.R/Makevars
找到该安装。你真的不需要弄乱你的 PATH
...