在macOS更新gdal后,安装R包sf 0.9.0出现错误。

5

我一直在用sfrproj工作,自从升级到Catalina/R 3.6.2版本后仍然正常。

我试图安装最新版本的sf(0.9.0),无论是从CRAN还是dev版本安装,均出现错误,configure: error: libproj not found in standard or given locations.

我已经彻底删除了我的计算机上的gdal和proj,并卸载、重新安装了两者,但仍然出现相同的问题。现在,我尝试安装我知道可以在我的计算机上工作的旧版本的sf(0.8.1),但安装也失败了。这真让我困惑!

GDAL 2.4.4,发布于2020/01/08

R v3.6.2

macOS 10.15.3

configure: CC: clang
configure: CXX: clang++ -std=gnu++11
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.4.4
checking GDAL version >= 2.0.1... yes
checking for gcc... clang
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 accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -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... 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... yes
checking GDAL: /usr/local/Cellar/gdal/2.4.4_2/share/gdal/pcs.csv readable... yes
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 2.4.4
checking proj.h usability... yes
checking proj.h presence... yes
checking for proj.h... yes
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... no
configure: error: libproj not found in standard or given locations.

for rgdal...

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /Library/Frameworks/R.framework/Resources
configure: CC: clang
configure: CXX: clang++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.4-7
checking for /usr/bin/svnversion... yes
configure: svn revision: 845
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.4.4
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking GDAL version <= 2.5 or >= 3.0... yes
checking gdal: linking with --libs only... yes
checking GDAL: gdal-config data directory readable... yes
checking GDAL: /usr/local/Cellar/gdal/2.4.4_2/share/gdal/pcs.csv readable... yes
configure: pkg-config proj not available
  set PKG_CONFIG_PATH to the directory containing proj.pc
configure: PROJ version not determined using pkg-config proj
configure: proj CPP flags:  -I/usr/local/Cellar/gdal/2.4.4_2/include
configure: PROJ LIBS:  -lproj
checking PROJ header API:... proj_api.h
checking proj_api.h presence and usability... no
configure: error: proj_api.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rgdal
2个回答

6

在挖掘多个小时后,终于找到了一个解决方案这里。如果其他人遇到了这个问题,可以参考。


2
谢谢,这个解决方案让我在长时间的挣扎后得以解救。您能否接受自己的答案,以便此帖被标记为已解决? - coletl

2
一个适用于我个人的解决方案。我已经发布在以下链接中: https://biostatsr.blogspot.com/2021/05/install-sf-from-github-source-in-macosx.html 在终端中,您必须安装MacBrew。如果没有,请使用以下命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

那么

brew install proj

brew install gdal

brew install geos

sudo R

然后在R中:

 library("devtools")

 install_github("r-spatial/sf", configure.args = "--with-proj-include=/usr/local/include --with-proj-lib=/usr/local/lib")

And...

packageVersion("sf")

[1] ‘0.9.9’


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接