【问题标题】:Can't install `proj4` package because libproj and/or proj_api.h not found in standard search locations无法安装“proj4”包,因为在标准搜索位置找不到 libproj 和/或 proj_api.h
【发布时间】:2019-10-11 18:20:31
【问题描述】:

我想安装需要安装proj4 包的ggalt 包,但是当我安装proj4 时会抛出错误libproj and/or proj_api.h not found in standard search locations

我的电脑是Mac,我用brew install proj安装了PROJ.4,R的版本是3.6.0_2。我在互联网上搜索了这个问题,但没有找到解决它的方法。我不是编码员,刚开始学习R,所以现在不知道该怎么做。

报错如下:

* installing *source* package ‘proj4’ ...
** package ‘proj4’ successfully unpacked and MD5 sums checked
** using staged installation
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... 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 proj_api.h usability... no
checking proj_api.h presence... no
checking for proj_api.h... no
checking for pj_init_plus in -lproj... yes
configure: error: libproj and/or proj_api.h not found in standard search locations.

*** Install PROJ.4 and if necessary set PKG_CPPFLAGS/PKG_LIBS accordingly.
ERROR: configuration failed for package ‘proj4’
* removing ‘/usr/local/lib/R/3.6/site-library/proj4’

The downloaded source packages are in
    ‘/private/var/folders/sn/1d6n55qs0zl522kcc769jq5h0000gn/T/RtmpNOkU64/downloaded_packages’

【问题讨论】:

  • proj 是否包含所需的proj_api.h?它位于哪里? brew ls --verbose proj 应该有助于回答这些问题。
  • proj_api.h 位于/usr/local/Cellar/proj/6.1.0/include/proj_api.h
  • 能否在安装proj4包之前将环境变量PKG_CPPFLAGS定义为-I/usr/local/Cellar/proj/6.1.0/include/
  • 我使用export PKG_CPPFLAGS="-I/usr/local/Cellar/proj/6.1.0/include"Sys.setenv("PKG_CPPFLAGS"="-I/usr/local/Cellar/proj/6.1.0/include") ,但不起作用
  • 错误信息保持不变?顺便说一句,你为什么不使用 CRAN 提供的二进制包。我试图重现该问题,并且安装包没有问题。

标签: r r-package proj


【解决方案1】:

我也遇到了这个烦人的问题。我能够手动构建它 - 但目前它是一个肮脏的黑客。请注意,我不是 C 程序员,所以它不会被修复。

我在proj_api.h的顶部找到了:

#ifndef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
#error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
#endif

我想我可以插入

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

src/p4.c 的第 7 行和包源的 configure 的第 1462 行之前(在这两种情况下都在 #include 之前)。

我想也可以从 proj_api.h 中删除该部分 - 但是我不知道它是否会破坏任何内容。

【讨论】:

    【解决方案2】:

    我正在运行 Pop!_OS 20.04 (Ubuntu fork) 并遇到了与 proj4 未安装 (R 3.6.3) 相同的问题。我不相信 libproj 还没有安装。我可以使用以下命令通过终端手动执行此操作:

    sudo apt-get install libproj-dev

    我重新启动了 R 并且能够安装 proj4

    【讨论】:

    • 可能还需要安装另一个库。 libproj-dev 在 Ubuntu 18.04 上是不够的。还必须安装libgdal-dev(请参阅github问题的答案之一:github.com/hrbrmstr/ggalt/issues/22
    猜你喜欢
    • 2019-08-10
    • 2020-07-27
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 2021-05-17
    • 2013-02-26
    • 2018-10-18
    • 2021-05-20
    相关资源
    最近更新 更多