由于在标准搜索位置中找不到libproj和/或proj_api.h,无法安装`proj4`软件包

7
我想安装ggalt程序包,但需要先安装proj4程序包。然而,当我安装proj4时,出现错误信息:libproj和/或proj_api.h未在标准搜索位置找到
我的电脑是Mac,并且已经使用brew install proj安装了PROJ.4,R的版本是3.6.0_2。我在互联网上搜索了这个问题,但没有找到解决方法。作为一名初学者,我不知道该怎么做。
下面是错误信息:
* 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 命令可以帮助回答这些问题。 - Ralf Stubner
proj_api.h is located in /usr/local/Cellar/proj/6.1.0/include/proj_api.h - juby
你能否在安装 proj4 包之前将环境变量 PKG_CPPFLAGS 定义为 -I/usr/local/Cellar/proj/6.1.0/include/ - Ralf Stubner
我使用 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"),但是没有起作用。 - juby
1
错误信息还是一样吗?顺便问一下,为什么你不使用CRAN提供的二进制包呢?我尝试重现了这个问题,但是该软件包已经成功安装了。 - Ralf Stubner
相关链接:https://dev59.com/xLLma4cB1Zd3GeqPd6Xz - DirtStats
2个回答

9

我正在运行Pop!_OS 20.04(Ubuntu分支),并遇到了与proj4不能安装的相同问题(R 3.6.3)。我不认为libproj已经安装。我能够在终端上通过以下命令手动进行安装:

sudo apt-get install libproj-dev

我重新启动了R,然后能够安装proj4


1
可能还需要安装另一个库。在Ubuntu 18.04上,仅安装libproj-dev是不够的。还必须安装libgdal-dev(请参见github问题的其中一个答案:https://github.com/hrbrmstr/ggalt/issues/22)。 - Cosmin Saveanu

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

在软件包源代码的configure的第1462行和src/p4.c的第7行之前(在两种情况下都是在#include之前),进行修改。
我想也可以从proj_api.h中删除该部分 - 但是我不知道是否会导致任何问题。

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