【问题标题】:How to solve `sf` installation error: proj_api.h not found in standard or given locations如何解决`sf`安装错误:在标准或给定位置找不到proj_api.h
【发布时间】:2021-04-06 07:03:30
【问题描述】:

我需要在 CentOS 7 中为 R 安装 sf 包。

gdalproj 的 repo 版本低于软件包所需的版本,因此我从源安装它们。

即使链接这些库,我总是会遇到同样的错误:

configure: GDAL: 3.2.0
checking proj.h usability... no
checking proj.h presence... no
checking for proj.h... no
checking proj_api.h usability... no
checking proj_api.h presence... no
checking for proj_api.h... no
configure: error: proj_api.h not found in standard or given locations.
ERROR: configuration failed for package ‘sf’

我尝试了不同的命令,并从不同的来源(CRAN、GitHub、本地)得到相同的错误。

例如:

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

proj_api.h 存在于指定路径:

locate proj_api.h
/usr/local/proj-7.2.0/include/proj_api.h

【问题讨论】:

标签: r centos7 sf proj


【解决方案1】:

解决方案非常简单。我只是将/usr/local/proj-7.2.0/include 中的文件复制到/usr/local/include,并将/usr/local/proj-7.2.0/lib 中的文件复制到/usr/local/lib

然后我在/etc/ld.so.conf.d 中添加了一个.conf 文件,其中包含/usr/local/proj-7.2.0/lib 的路径并运行sudo ldconfig

似乎其他包在自定义位置识别projsf 没有。特别是,这部分什么都不做"--with-proj-lib=/usr/local/proj-7.2.0/lib", "--with-proj-include=/usr/local/proj-7.2.0/include"

安装sf 的命令行是install.packages("sf", configure.args="--with-gdal-config=/usr/local/gdal-3.2.0/bin/gdal-config --with-geos-config=/usr/local/bin/geos-config"),没有引用proj

无需更改操作系统或降级库。

【讨论】:

    【解决方案2】:

    我今天遇到了同样的问题,但我无法使用其他解决方案,因为我没有 root 访问权限。问题是因为配置文件使用pkgconfig 来检查proj 是否存在,我需要将proj.pc 的路径添加到pkgconfig 检查的位置。

    之后

    export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/home/directory/local/proj_install/lib/pkgconfig

    install.packages("sf", configure.args="--with-proj-include=/home/directory/local/proj_install/include --with-proj-lib=/home/directory/local/proj_install/lib --with-proj-data=/home/directory/local/proj_install/share/proj")

    工作正常。

    【讨论】:

      猜你喜欢
      • 2020-07-27
      • 2019-08-10
      • 2019-10-11
      • 1970-01-01
      • 2021-05-20
      • 2019-09-09
      • 1970-01-01
      • 2021-12-08
      • 2013-07-26
      相关资源
      最近更新 更多