Как связать proj для успешной установки пакета sf на CentOS 6?

Я пытаюсь установить пакет sf для R, следуя этому ответу на CentOS 6:

https://stackoverflow.com/a/51369036/826500

Но это не удается при достижении части proj с сообщением:

proj.cpp:31:2: error: 'proj_context_set_search_paths' was not declared in this scope...

Я попросил помощи на странице проблем GitHub с пакетом sf, но, похоже, возникла проблема с настройкой conda/GDAL/PROJ, возможно, связанная с этой проблемой: https://trac.osgeo.org/gdal/wiki/BuildingOnUnixGDAL25dev

При попытке CXXFLAGS="-DPROJ_RENAME_SYMBOLS -O2" CFLAGS=$CXXFLAGS ./configure --prefix=/my/install/prefix --disable-static получаю ошибку:

CXXFLAGS=-DPROJ_RENAME_SYMBOLS -O2: command not found

Поскольку это мой первый раз с такой установкой, я не совсем уверен, в каком направлении двигаться, чтобы избежать новых сложностей и успешно установить пакет.

Полный журнал установки пакета sf выглядит следующим образом:

 install.packages('sf', repos='https://cran.rstudio.com/')
Installing package into ‘/home/relexteriores/R/x86_64-conda_cos6-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
--2020-12-15 12:05:03--  https://cran.rstudio.com/src/contrib/sf_0.9-6.tar.gz
Connecting to 168.176.239.40:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 4160758 (4.0M) [application/x-gzip]
Saving to: “/tmp/RtmpcKdCbm/downloaded_packages/sf_0.9-6.tar.gz”

100%[==========================================================>] 4,160,758   5.03M/s   in 0.8s

2020-12-15 12:05:04 (5.03 MB/s) - “/tmp/RtmpcKdCbm/downloaded_packages/sf_0.9-6.tar.gz” saved [4160758/4160758]

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: /opt/miniconda2/envs/rsf/bin/x86_64-conda_cos6-linux-gnu-cc
configure: CXX: /opt/miniconda2/envs/rsf/bin/x86_64-conda_cos6-linux-gnu-c++
checking for gdal-config... /opt/miniconda2/envs/rsf/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.3
checking GDAL version >= 2.0.1... yes
checking for gcc... /opt/miniconda2/envs/rsf/bin/x86_64-conda_cos6-linux-gnu-cc
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 /opt/miniconda2/envs/rsf/bin/x86_64-conda_cos6-linux-gnu-cc accepts -g... yes
checking for /opt/miniconda2/envs/rsf/bin/x86_64-conda_cos6-linux-gnu-cc option to accept ISO C89... none needed
checking how to run the C preprocessor... /opt/miniconda2/envs/rsf/bin/x86_64-conda_cos6-linux-gnu-cpp
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: /opt/miniconda2/envs/rsf/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
configure: GDAL: 2.3.3
checking proj.h usability... yes
checking proj.h presence... yes
checking for proj.h... yes
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... yes
checking for geos-config... /opt/miniconda2/envs/rsf/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.7.1
checking GEOS version >= 3.4.0... yes
checking geos_c.h usability... yes
checking geos_c.h presence... yes
checking for geos_c.h... yes
checking geos: linking with -L/opt/miniconda2/envs/rsf/lib -lgeos_c... yes
configure: Package CPP flags:   -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include
configure: Package LIBS:  -L/opt/miniconda2/envs/rsf/lib -lgdal -lproj  -L/opt/miniconda2/envs/rsf/lib -lgdal -L/opt/miniconda2/envs/rsf/lib -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c RcppExports.cpp -o RcppExports.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c bbox.cpp -o bbox.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c gdal.cpp -o gdal.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c gdal_geom.cpp -o gdal_geom.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c gdal_read.cpp -o gdal_read.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c gdal_utils.cpp -o gdal_utils.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c gdal_write.cpp -o gdal_write.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c geos.cpp -o geos.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c hex.cpp -o hex.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c ops.cpp -o ops.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c polygonize.cpp -o polygonize.o
x86_64-conda_cos6-linux-gnu-c++ -std=gnu++11 -I"/opt/miniconda2/envs/rsf/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/opt/miniconda2/envs/rsf/include -I/opt/miniconda2/envs/rsf/include -I"/opt/miniconda2/envs/rsf/lib/R/library/Rcpp/include" -DNDEBUG -D_FORTIFY_SOURCE=2 -O2  -I/opt/miniconda2/envs/rsf/include -Wl,-rpath-link,/opt/miniconda2/envs/rsf/lib  -fpic  -fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/opt/miniconda2/envs/rsf/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/opt/miniconda2/envs/rsf=/usr/local/src/conda-prefix  -c proj.cpp -o proj.o
proj.cpp: In function 'Rcpp::LogicalVector CPL_set_data_dir(std::__cxx11::string)':
proj.cpp:31:2: error: 'proj_context_set_search_paths' was not declared in this scope
  proj_context_set_search_paths(PJ_DEFAULT_CTX, 1, &cp);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proj.cpp:31:2: note: suggested alternative: 'proj_context_destroy'
  proj_context_set_search_paths(PJ_DEFAULT_CTX, 1, &cp);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  proj_context_destroy
proj.cpp: In function 'Rcpp::LogicalVector CPL_use_proj4_init_rules(Rcpp::IntegerVector)':
proj.cpp:36:2: error: 'proj_context_use_proj4_init_rules' was not declared in this scope
  proj_context_use_proj4_init_rules(PJ_DEFAULT_CTX, v[0]);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proj.cpp:36:2: note: suggested alternative: 'CPL_use_proj4_init_rules'
  proj_context_use_proj4_init_rules(PJ_DEFAULT_CTX, v[0]);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CPL_use_proj4_init_rules
proj.cpp: In function 'Rcpp::List CPL_proj_is_valid(std::__cxx11::string)':
proj.cpp:50:2: error: 'proj_context_use_proj4_init_rules' was not declared in this scope
  proj_context_use_proj4_init_rules(PJ_DEFAULT_CTX, 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proj.cpp:50:2: note: suggested alternative: 'CPL_use_proj4_init_rules'
  proj_context_use_proj4_init_rules(PJ_DEFAULT_CTX, 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CPL_use_proj4_init_rules
proj.cpp: In function 'Rcpp::NumericMatrix CPL_proj_direct(Rcpp::CharacterVector, Rcpp::NumericMatrix, bool, bool, bool)':
proj.cpp:83:2: error: 'proj_context_use_proj4_init_rules' was not declared in this scope
  proj_context_use_proj4_init_rules(PJ_DEFAULT_CTX, 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proj.cpp:83:2: note: suggested alternative: 'CPL_use_proj4_init_rules'
  proj_context_use_proj4_init_rules(PJ_DEFAULT_CTX, 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CPL_use_proj4_init_rules
proj.cpp:88:7: error: 'proj_normalize_for_visualization' was not declared in this scope
   P = proj_normalize_for_visualization(PJ_DEFAULT_CTX, P);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [/opt/miniconda2/envs/rsf/lib/R/etc/Makeconf:175: proj.o] Error 1
ERROR: compilation failed for package ‘sf’
* removing ‘/home/relexteriores/R/x86_64-conda_cos6-linux-gnu-library/3.6/sf’

The downloaded source packages are in
        ‘/tmp/RtmpcKdCbm/downloaded_packages’
Warning message:
In install.packages("sf", repos = "https://cran.rstudio.com/") :
  installation of package ‘sf’ had non-zero exit status

person Memochipan    schedule 15.12.2020    source источник


Ответы (1)


У меня были подобные проблемы с Ubuntu; это было вызвано несколькими экземплярами PROJ на моей машине (я установил новую версию из исходного кода, и в дистрибутив была включена старая версия).

В моем случае было необходимо указать установщику {sf} правильный экземпляр PROJ.

install.packages("sf", configure.args = "--with-proj-lib=/usr/local/lib/")

Вы также можете найти полезным этот ответ для CentOS: установка пакета sf с библиотеки в нестандартных местах

person Jindra Lacko    schedule 22.12.2020
comment
Спасибо. Ваш совет позволил мне сделать еще один шаг вперед. Теперь он распознает пакет gdal, но не пакет proj. Пробовал это install.packages('sf', type = "source", configure.args='--with-gdal-config=/usr/local/gdal-2.4.3/bin/gdal-config --with-proj-lib=/usr/local/proj-5.2.0/lib') и получил checking GDAL: checking whether PROJ is available for linking:... yes checking GDAL: checking whether PROJ is available fur running:... ./gdal_proj: error while loading shared libraries: libgdal.so.20: cannot open shared object file: No such file or directory no - person Memochipan; 23.12.2020
comment
Возможно, вам придется перекомпилировать gdal, чтобы убедиться, что он связан с правильным PROJ. Если подумать: вы можете установить PROJ (сначала) и GDAL (после) из исходного кода. Ваши версии довольно устарели. Особенно хорошей идеей является PROJ выше 6.0.0, так как вокруг этой версии были критические изменения. - person Jindra Lacko; 23.12.2020
comment
Действительно, я установил proj раньше gdal и указал путь к нему при установке. Я следовал этому руководству thelinuxcluster.com /2019/12/17/compile-gdal-2-4-3-on-centos-7, но по какой-то причине sf не распознает путь proj. - person Memochipan; 24.12.2020
comment
Я пробовал с последними версиями (GDAL 3.2.0 и PROJ 7.2.0) и получил ту же ошибку: checking GDAL: checking whether PROJ is available for linking:... yes checking GDAL: checking whether PROJ is available fur running:... ./gdal_proj: error while loading shared libraries: libgdal.so.28: cannot open shared object file: No such file or directory no configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available? ERROR: configuration failed for package ‘sf’ - person Memochipan; 25.12.2020