首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在非标准位置安装包含库的sf包

问在非标准位置安装包含库的sf包
EN

Stack Overflow用户
提问于 2019-04-19 18:39:32
回答 1查看 1.4K关注 0票数 1

所需的库位于非标准位置,我可以通过以下命令安装rgdal:

代码语言:javascript
复制
install.packages('rgdal', type = "source", 
configure.args=c('--with-gdal-config=/home/programs/anaconda3/bin/gdal-config',
'--with-proj-include=/home/programs/anaconda3/include',
'--with-proj-lib=/home/programs/anaconda3/lib'))

但是我不能安装sf包。它一直在说configure: error: proj_api.h not found in standard or given locations.。安装代码和输出如下。你有什么提示吗?

代码语言:javascript
复制
install.packages('sf', type = "source", 
configure.args='--with-gdal-config=/home/programs/anaconda3/bin/gdal-config --with-geos-config=/home/programs/anaconda3/bin/geos-config --with-proj-include=/home/programs/anaconda3/include/ --with-proj-lib=/home/programs/anaconda3/lib/')
代码语言:javascript
复制
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
configure: CC: gcc -m64 -std=gnu99
configure: CXX: g++ -m64 -std=gnu++11
configure: gdal-config set to /home/programs/anaconda3/bin/gdal-config
checking gdal-config exists... yes
checking gdal-config executable... yes
checking gdal-config usability... yes
configure: GDAL: 2.4.1
checking GDAL version >= 2.0.0... yes
checking for gcc... gcc -m64 -std=gnu99
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 gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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: /home/programs/anaconda3/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
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’
* removing ‘/usr/lib64/R/library/sf’

R设置信息:

代码语言:javascript
复制
platform       x86_64-redhat-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          3
minor          5.2
year           2018
month          12
day            20
svn rev        75870
language       R
version.string R version 3.5.2 (2018-12-20)
nickname       Eggshell Igloo
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-29 23:20:00

感谢所有评论的人;这个问题源于CentOS的sudo设置。操作系统设置为用户环境变量在sudo环境中不可用,因此在用户.bashrc文件中设置环境变量无法解决此问题。因此,要安装sf包,我必须在命令行中使用sudo和正确的环境变量启动R,然后在R中安装sf包。

首先,使用所需的环境变量运行R,

代码语言:javascript
复制
sudo PKG_CONFIG_PATH="/home/programs/anaconda3/lib/pkgconfig/" LD_LIBRARY_PATH="/home/programs/anaconda3/lib" R

第二步,安装sf。

代码语言:javascript
复制
remotes::install_github("r-spatial/sf", configure.args = "--with-gdal-config=/home/programs/anaconda3/bin/gdal-config --with-geos-config=/home/programs/anaconda3/bin/geos-config --with-proj-include=/home/programs/anaconda3/include/ --with-proj-lib=/home/programs/anaconda3/lib/")

再次,很抱歉占用你的时间,我希望这篇文章能帮助到一些人。

请参阅:https://github.com/r-spatial/sf/issues/335#issuecomment-484985276

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55760563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档