gpt4 book ai didi

r - 无法在 MacOS M1 Monterey 上安装 stringi R 包

转载 作者:行者123 更新时间:2023-12-05 08:03:30 34 4
gpt4 key购买 nike

我无法在使用新 M1 和 arm64 架构的 Macbook Pro(运行 MacOS Monterey)上安装 R 包 stringi。 SO 上有许多描述类似问题的帖子,但我收到的错误消息是我以前从未见过的。

当我在 RStudio 中运行 install.packages("stringi") 时,我收到以下错误消息:

stri_brkiter.cpp:60:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^

我猜这里发生了某种编译器不匹配——不应该有来自 CRAN 包的“未声明的标识符”错误。不过,我不确定如何解决这个问题,而且我无法在网上找到其他人收到类似消息的任何示例。我在网上见过 很多 类似的错误,但是对这些错误的修复并没有帮助我解决这个 isNull() 错误。

注意:以上几行只是消息输出的错误部分。请参阅下面的完整错误文本。

> install.packages("stringi")
Installing package into ‘/Users/<username>/r_libs’
(as ‘lib’ is unspecified)
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘stringi’
Do you want to attempt to install these from sources? (Yes/no/cancel) yes
installing the source package ‘stringi’

Content type 'application/x-gzip' length 7578882 bytes (7.2 MB)
==================================================
downloaded 7.2 MB

* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
** using staged installation
checking for R_HOME... /Library/Frameworks/R.framework/Resources
checking for R... /Library/Frameworks/R.framework/Resources/bin/R
checking for endianness... little
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... no
checking for cat... /bin/cat
checking for local ICUDT_DIR... icu69/data
checking for gcc... clang -arch arm64
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang -arch arm64 accepts -g... yes
checking for clang -arch arm64 option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -arch arm64 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking elf.h usability... no
checking elf.h presence... no
checking for elf.h... no
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++11 accepts -g... yes
checking whether the C++ compiler supports the long long type... yes
checking whether the compiler implements namespaces... yes
checking whether the compiler supports Standard Template Library... yes
checking whether std::map is available... yes
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking with pkg-config for the system ICU4C... 70.1
checking for ICU4C >= 55... yes
checking for additional required CPPFLAGS, LDFLAGS, and LIBS... done
checking whether an ICU4C-based project can be built... yes
checking programmatically for sufficient U_ICU_VERSION_MAJOR_NUM... yes
checking programmatically if U_CHARSET_IS_UTF8 is defined and set... yes
checking the capabilities of the ICU data library (ucnv, uloc, utrans)... yes
checking the capabilities of the ICU data library (ucol)... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/uconfig_local.h
config.status: creating src/install.libs.R

*** stringi configure summary:
ICU_FOUND=1
STRINGI_CXXSTD=CXX_STD=CXX11
STRINGI_CFLAGS= -fPIC
STRINGI_CPPFLAGS=-I. -I/opt/homebrew/Cellar/icu4c/70.1/include -UDEBUG -DNDEBUG
STRINGI_CXXFLAGS= -fPIC
STRINGI_LDFLAGS=-L/opt/homebrew/Cellar/icu4c/70.1/lib
STRINGI_LIBS=-licui18n -licuuc -licudata

*** Compiler settings used:
CC=clang -arch arm64
LD=clang++ -arch arm64 -std=gnu++14
CFLAGS=-falign-functions=64 -Wall -g -O2 -fPIC
CPPFLAGS=-I/opt/R/arm64/include -UDEBUG -DNDEBUG
CXX=clang++ -arch arm64 -std=gnu++11
CXXFLAGS=-falign-functions=64 -Wall -g -O2 -fPIC
LDFLAGS=
LIBS=

** libs
clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I. -I/opt/homebrew/Cellar/icu4c/70.1/include -UDEBUG -DNDEBUG -I/opt/R/arm64/include -fPIC -fPIC -falign-functions=64 -Wall -g -O2 -c stri_brkiter.cpp -o stri_brkiter.o
stri_brkiter.cpp:60:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^
stri_brkiter.cpp:130:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^
stri_brkiter.cpp:171:9: error: use of undeclared identifier
'isNull'
if (isNull(opts_brkiter)) {
^
3 errors generated.
make: *** [stri_brkiter.o] Error 1
ERROR: compilation failed for package ‘stringi’
* removing ‘/Users/<username>/r_libs/stringi’
* restoring previous ‘/Users/<username>/r_libs/stringi’

The downloaded source packages are in
‘/private/var/folders/qc/whkk090506v2qjy698yf25m80000gq/T/RtmpvLUDID/downloaded_packages’
Warning message:
In install.packages("stringi") :
installation of package ‘stringi’ had non-zero exit status

我尝试在 R Studio 和命令行中安装 stringi,一些 SO 帖子建议这可能更有效,但我通过这两种方法收到相同的错误。

最初,编译器无法找到 ICU4C 库(这也阻止了我安装 stringi),但我能够将 pkg-config 指向该库通过运行 brew link icu4c --force 并解决了它。

我尝试过的其他命令(没有修复它):

install.packages('stringi', configure.args='--disable-cxx11')
install.packages("stringi", configure.args = "--with-extra-cxxflags='--std=c++11'")

完全删除我的 Makevars 文件并没有解决问题。

我在 SO 和 Github 上查看了许多主要/热门的相关问题(包括 thisthisthisthisthis 等)。不过,我认为我已经达到了对这些东西的理解边缘。

我公认的非专家假设是,这与我下载的编译器、我完成的 M1 架构解决方法和/或我的 Makevars 文件有关,因为我安装了 stringi 在以前的(较旧的)Macbook 上没有任何问题。

系统信息:

  • 操作系统:Mac OS Monterey (v 12.2) w/Apple M1 Max 芯片
  • R:R 版本 4.2.0
  • RStudio:RStudio 版本 1.4.1717
  • Xcode:Xcode 版本 13.3.1
  • 使用 Homebrew 安装了 gcc/gfortran 和其他库,并将下载位置添加到 $PATH

我的 Makevars 文件:

此文件是根据 here 的建议构建的, here , here , 和 here .

CC=/opt/homebrew/bin/gcc-11
CXX=/opt/homebrew/bin/g++-11

FC=/opt/homebrew/bin/gfortran-11
F77=/opt/homebrew/bin/gfortran-11
FLIBS=-L/opt/homebrew/opt/gfortran/lib -lgfortran -lquadmath -lm

CFLAGS=-I/opt/homebrew/include
CXXFLAGS=-O3 -Wall -pipe -Wno-unused -pedantic
CXX11FLAGS=-O3 -Wall -pipe -Wno-unused -pedantic

这个错误对任何人来说都很眼熟,或者有人对我下一步可以做什么来解决这个问题有建议吗?我已经尝试了很多解决方法,所以如果我遗漏了任何内容,我深表歉意,如果有任何其他信息可能有用,请告诉我!

谢谢!

最佳答案

除非您绝对需要源代码编译版本,否则目前有一个二进制 arm 版本。 (显然以后的人需要改版本号)

install.packages("https://cran.r-project.org/bin/macosx/big-sur-arm64/contrib/4.1/stringi_1.7.6.tgz", 
repos = NULL, type = .Platform$pkgType)

我想知道在您尝试此操作时 Rstudio 的默认存储库是否在这方面不完整?

关于r - 无法在 MacOS M1 Monterey 上安装 stringi R 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72524621/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com