请指出我遗漏的地方:
openSUSE 11.3
xx@linux-y3pi:~/Desktop/R> sudo R CMD INSTALL rgdal_0.7-12.tar.gz
root's password:
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: gdal-config: gdal-config
checking gdal-config usability... ./configure: line 1353: gdal-config: command not found
no
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not installed the GDAL libraries, you can
download the source from http://www.gdal.org/
If you have installed the GDAL libraries, then make sure that
gdal-config is in your path. Try typing gdal-config at a
shell prompt and see if it runs. If not, use:
--configure-args='--with-gdal-config=/usr/local/bin/gdal-config'
with appropriate values for your installation.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/lib64/R/library/rgdal’
xx@linux-y3pi:~/Desktop/R> whereis gdal-config
gdal-config: /usr/local/bin/gdal-config
xx@linux-y3pi:~/Desktop/R> gdal-config
Usage: gdal-config [OPTIONS]
Options:
[--prefix[=DIR]]
[--libs]
[--dep-libs]
[--cflags]
[--datadir]
[--version]
[--ogr-enabled]
[--formats]
xx@linux-y3pi:~/Desktop/R>
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
>
xx@linux-y3pi:~/Desktop/R> gdal-config --version
1.9.0
xx@linux-y3pi:~/Desktop/R> proj
Rel. 4.8.0, 6 March 2012
usage: proj [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]
linux-y3pi:~ # $PATH
bash: /home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/home/xx/qtsdk-2010.05/qt/bin:/home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/xx/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games: No such file or directory
在 Ubuntu 18.04 中
我通过
sudo apt install libgdal-dev
解决了这个问题
希望有人觉得这有帮助。上面的一些答案似乎已经过时且冗长。
在早期版本中(有 apt-get)
sudo apt-get install libgdal-dev
除了
部署的普通包之外,您还需要带有标头和共享库链接的
-dev
包来进行开发。就发行版而言,有两种不同的用例。
在我的发行版上:
edd@max:/tmp$ dpkg -l | grep gdal | cut -c-72
ii libgdal1-1.7.0 1.7.3-6ubuntu3
ii libgdal1-dev 1.7.3-6ubuntu3
edd@max:/tmp$
和
R CMD INSTALL rgdal_0.7-8.tar.gz
工作得很好,正如您对 CRAN 包所期望的那样,考虑到 CRAN 上的所有构建时检查。
2016 年末更新: 正如@JoshO'Brien 在评论中指出的那样
小更新:2016 年,运行 Ubuntu 14.04.2,
似乎 已替换libgdal1h
(尽管仍需要libgdal1
)。至少 当我尝试libgdal1-dev
时,我收到了这样的错误apt-get install libgdal1
对于 Ubuntu 16.04,相应的行是
sudo apt-get install libgdal1i
这种上游库的重命名很常见;诸如
apt-cache search libgdal
之类的东西可以帮助找到当前的包名称。但重要的关键是“抽象”开发包libgdal-dev
是构建所需的全部,因为它通过依赖项拉入“具体”当前运行时包(此处:libgdal1i
)。
您可以使用 apt-file 包来查找哪个包包含您要查找的丢失文件。
首先使用命令 apt-get install apt-file
安装
apt-file
apt-file update
更新 apt-file
apt-file search gdal-config
对于我的情况,我在从 svn 配置gras-7.1 时遇到了同样的错误。如下图:
$ ./configure
...more...
checking whether to use GDAL... yes
checking for gdal-config... /usr/bin/gdal-config
...more....
./configure: 1: ./configure: /usr/bin/gdal-config: not found
./configure: 6093: test: =: unexpected operator
configure: error: *** Unable to locate GDAL library.
但是,在使用 apt-file 查找 gdal-config 文件(如下所示)后,我能够在安装软件包 libgdal1-dev
后解决该错误$ apt-file search gdal-config
结果
libgdal1-dev: /usr/bin/gdal-config
所以我安装了libgdal1-dev,如下图:
$ sudo apt-get install libgdal1-dev
发生这种情况是因为包“rgdal”配置失败 所以我们必须安装必要的依赖项。
需要 libgdal-dev 和 libproj-dev 软件包:
sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev
然后通过
安装rgdalinstall.packages("rgdal")
通过
加载 rgdallibrary(rgdal)
在 macOS
brew install gdal
删除了错误
gdal-config 未找到
在 CentOS 6 上试试这个
sudo yum install gdal gdal-python gdal-devel mapserver mapserver-python libxml2 libxml2-python python-lxml python-pip python-devel gcc
阅读参考手册。
从源代码构建的系统要求:GDAL >= 1.6.0 库 来自 http://trac.osgeo.org/gdal/wiki/DownloadSource 和 PROJ.4(项目 >= 4.4.9) 来自 http://trac.osgeo.org/proj/;
即使在
brew install gdal
之后,我的Mac Monterrey仍然继续抱怨。
这个 github 问题中的建议确实起到了作用
install.packages("sf", type = "source", configure.args =
'--with-gdal-lib=/opt/homebrew/opt/gdal/lib/
--with-sqlite3-lib=/opt/homebrew/opt/sqlite/lib/
--with-gdal-config=/opt/homebrew/bin/gdal-config
--with-proj-share=/opt/homebrew/opt/proj/share/
--with-proj-lib=/opt/homebrew/opt/proj/lib
--with-proj-include=/opt/homebrew/opt/proj/include/
--with-geos-config=/opt/homebrew/opt/geos/bin/geos-config')
今天在我没有管理权限的 Linux CentOS 6.10 上也出现了同样的问题。
我做了什么:
a) 创建专用于我的 R 版本的 conda 环境
conda create --name MYR
b) 激活环境
source activate MYR
c) 安装 R
conda install -c conda-forge r-base
d) 安装 libgdal
conda install -c conda-forge libgdal
这解决了我的问题。我的 R 版本是 4.1.3。我想其他版本应该可以工作。
对于 manjora 或 archlinux,只需尝试:
yay -S gdal