在非标准位置使用库安装sf软件包 [英] installing sf package with libraries in non-standard locations

查看:96
本文介绍了在非标准位置使用库安装sf软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The required libraries are in non-standard locations and I can install rgdal by the command below:

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:错误:在标准位置或给定位置找不到proj_api.h..安装代码和输出如下.你有什么提示吗?

But I can't install sf package. It keeps saying configure: error: proj_api.h not found in standard or given locations.. The installation code and output is below. Do you have any hint?

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/')

* 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设置信息:

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

推荐答案

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

Thanks to all who comments; this issue was originated from CentOS's sudo settings. OS was set up that user environment variables will not be available in sudo environment, so setting an environment variable in user .bashrc file wouldn't solve the issue. Hence, to install sf package, I have to start R with sudo and with correct environment variables in command line, then install sf package in R.

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

First, run R with required environment variables,

sudo PKG_CONFIG_PATH="/home/programs/anaconda3/lib/pkgconfig/" LD_LIBRARY_PATH="/home/programs/anaconda3/lib" R

第二,安装 sf .

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/")

再次,请原谅我花时间,希望这篇文章对某人有所帮助.

Again, excuse me for spending your time, I hope this post helps someone.

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

这篇关于在非标准位置使用库安装sf软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆