установка пакета sf с библиотеками в нестандартные места

Необходимые библиотеки находятся в нестандартных местах, и я могу установить rgdal с помощью команды ниже:

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.. Код установки и вывод ниже. У вас есть намек?

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

person Sezen    schedule 19.04.2019    source источник
comment
Вы также должны установить следующие LDFLAGS: -L/home/programs/anaconda3/lib -Wl,-R,/home/programs/anaconda3/lib -Wl,--enable-new-dtags (при условии, что они передаются через компилятор).   -  person jww    schedule 19.04.2019
comment
Я только что попробовал команду sudo LDFLAGS="-L/home/programs/anaconda3/lib -Wl,-R,/home/programs/anaconda3/lib -Wl,--enable-new-dtags" R CMD INSTALL sf_0.7-3.tar.gz --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', но она все еще жалуется, та же ошибка proj_api.h не найдена.   -  person Sezen    schedule 19.04.2019
comment
У меня была аналогичная проблема с пакетом lwgeom. Нашел этот комментарий github, который решил мою проблему.   -  person Guillermo.D    schedule 29.04.2019


Ответы (1)


Спасибо всем, кто комментирует; эта проблема возникла из-за настроек CentOS sudo. ОС была настроена так, что переменные среды пользователя не будут доступны в среде sudo, поэтому установка переменной среды в файле пользователя .bashrc не решит проблему. Следовательно, чтобы установить пакет sf, мне нужно запустить R с sudo и с правильными переменными среды в командной строке, а затем установить пакет sf в R.

Сначала запустите R с необходимыми переменными среды,

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

Еще раз извините, что трачу ваше время, надеюсь, этот пост кому-то поможет.

См.: https://github.com/r-spatial/sf/issues/335#issuecomment-484985276

person Sezen    schedule 29.04.2019