使用自制软件中的 geos/proj/gdal 从 Mac M1 上的源空间 R 库安装

问题描述

我正在尝试从源代码安装 sf 包,以便使用由 homebrew 安装的最新版本的 geos/gdal/proj 运行它。我正在使用带有 MacOS BigSur 11.3 的 Apple Silicon M1 计算机。似乎我的问题与这个新的 Apple 硅芯片有关。如果你们中的任何人已经遇到了这个问题并且可以分享一些很棒的技巧。

这是我在 R 中的命令:

install_github("r-spatial/sf",configure.args = c("--with-proj-lib=/opt/homebrew/bin/","--with-gdal-config=/opt/homebrew/bin/gdal-config","--with-geos-config=/opt/homebrew/bin/geos-config"))

响应是

Downloading GitHub repo r-spatial/sf@HEAD
✓  checking for file ‘/private/var/folders/50/g22y7v993hq6m6r4m3mm05_r0000gn/T/Rtmp5KWH5H/remotesc7c51a94ebf/r-spatial-sf-c99226b/DESCRIPTION’ (418ms)
─  preparing ‘sf’:
✓  checking DESCRIPTION Meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts (629ms)
─  checking for empty or unneeded directories
─  building ‘sf_0.9-9.tar.gz’
   
* installing *source* package ‘sf’ ...
** using staged installation
configure: CC: clang -mmacosx-version-min=10.13
configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++11
configure: gdal-config set to /opt/homebrew/bin/gdal-config
checking gdal-config exists... yes
checking gdal-config executable... yes
checking gdal-config usability... yes
configure: GDAL: 3.2.2
checking GDAL version >= 2.0.1... yes
checking for gcc... clang -mmacosx-version-min=10.13
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 -mmacosx-version-min=10.13 accepts -g... yes
checking for clang -mmacosx-version-min=10.13 option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -mmacosx-version-min=10.13 -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 gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... no
checking GDAL: linking with --libs and --dep-libs... no
ld: warning: ignoring file /opt/homebrew/Cellar/gdal/3.2.2_4/lib/libgdal.dylib,building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_GDALAllRegister",referenced from:
      _main in gdal_test-e29770.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)
ld: warning: directory not found for option '-L/opt/homebrew/Cellar/libdap/3.20.7/lib64'
ld: library not found for -lcrypto
clang: error: linker command Failed with exit code 1 (use -v to see invocation)
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration Failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf’
* restoring prevIoUs ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/50/g22y7v993hq6m6r4m3mm05_r0000gn/T//Rtmp5KWH5H/filec7c4271077b/sf_0.9-9.tar.gz’ had non-zero exit status

当我尝试对 rgdal 做同样的事情时,我得到了相同的结果。如果我用 rgeos 来做,我会得到类似的错误

...
checking geos: linking with libgeos_c... no
checking geos: linking with -L/opt/homebrew/Cellar/geos/3.9.1/lib -lgeos_c -lgeos -lm... no
ld: warning: ignoring file /opt/homebrew/Cellar/geos/3.9.1/lib/libgeos_c.dylib,building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/geos/3.9.1/lib/libgeos.dylib,building for macOS-x86_64 but attempting to link with file built for macOS-arm64
...

我对此有点陌生,所以如果您需要更多信息,请告诉我。 谢谢,

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)