terra icon indicating copy to clipboard operation
terra copied to clipboard

Installation failed: RcppFunctions.cpp:14:10: fatal error: proj.h: No such file or directory

Open sabdall33 opened this issue 2 years ago • 3 comments

I'm trying to install terra for a monocle3 installation. I think there's an issue with the proj4.8 on centos 7 missing proj.h file?

[root@wsu177 ~]# R

R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> remotes::install_github("rspatial/terra")
Downloading GitHub repo rspatial/terra@HEAD

✔  checking for file ‘/tmp/RtmpY7QIio/remotes5c0627363df5/rspatial-terra-fab37e5/DESCRIPTION’ (383ms)
─  preparing ‘terra’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts (340ms)
─  checking for empty or unneeded directories
─  building ‘terra_1.6-2.tar.gz’

* installing *source* package ‘terra’ ...
** using staged installation
configure: CC: gcc
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /wsu/el7/gnu7/gdal/3.0.1/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.0.1
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc
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 accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/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: /wsu/el7/gnu7/gdal/3.0.1/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 3.0.1
configure: pkg-config proj exists, will use it
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.8.0
checking for pj_init_plus in -lproj... yes
checking PROJ: epsg found and readable... yes
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.4.2
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/usr/lib64 -lgeos_c... yes
configure: Package CPP flags:    -I/wsu/el7/gnu7/gdal/3.0.1/include -I/usr/include
configure: Package LIBS: -lproj     -L/wsu/el7/gnu7/gdal/3.0.1/lib -lgdal -L/usr/lib64 -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I"/wsu/el7/gnu7/R/R-4.1.0/lib64/R/include" -DNDEBUG -I/wsu/el7/gnu7/gdal/3.0.1/include -I/usr/include -I'/wsu/el7/gnu7/R/R-4.1.0/lib64/R/library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/wsu/el7/gnu7/R/R-4.1.0/lib64/R/include" -DNDEBUG -I/wsu/el7/gnu7/gdal/3.0.1/include -I/usr/include -I'/wsu/el7/gnu7/R/R-4.1.0/lib64/R/library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c RcppFunctions.cpp -o RcppFunctions.o
RcppFunctions.cpp:14:10: fatal error: proj.h: No such file or directory
 #include "proj.h"
          ^~~~~~~~
compilation terminated.
make: *** [RcppFunctions.o] Error 1
ERROR: compilation failed for package ‘terra’
* removing ‘/wsu/el7/gnu7/R/R-4.1.0/lib64/R/library/terra’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/RtmpY7QIio/file5c063da67fc0/terra_1.6-2.tar.gz’ had non-zero exit status

sabdall33 avatar Jul 19 '22 18:07 sabdall33

In most cases these problems stem from having multiple installations of a library. It could also be that you need to do something like this (point to where PROJ is)

 remotes::install_github("rspatial/terra", configure.args = "--with-proj-lib=/usr/local/lib/")

rhijmans avatar Jul 19 '22 20:07 rhijmans

Also, per the DESCRIPTION, I think PROJ >= 4.9.3 is required. This is when proj.h was added https://github.com/rspatial/terra/blob/434e07ca4467310e01e20bbcbde1b15cb4528d09/DESCRIPTION#L10

If latest CentOS 7 version of PROJ.4/proj is 4.8.0 you may need to get a newer version installed manually from outside your package manager.

brownag avatar Jul 19 '22 20:07 brownag

Appreciate the responses! I've compiled proj 6.1.1 from the source and removed the proj 4.8 install, and pointed to where it is like so after seeing some other examples in other issues:

install.packages("terra", repos="https://rspatial.r-universe.dev", configure.args="--with-proj-include=/wsu/el7/gnu7/proj/6.1.1/include --with-proj-lib=/wsu/el7/gnu7/proj/6.1.1/lib --with-proj-data=/wsu/el7/gnu7/proj/6.1.1/share/proj")

Not sure if that's correct! Because trying that out wasn't successful..

install.packages("terra", repos="https://rspatial.r-universe.dev", configure.args="--with-proj-include=/wsu/el7/gnu7/proj/6.1.1/include --with-proj-lib=/wsu/el7/gnu7/proj/6.1.1/lib --with-proj-data=/wsu/el7/gnu7/proj/6.1.1/share/proj") Content type 'application/x-gzip' length 1323081 bytes (1.3 MB) downloaded 1.3 MB

  • installing source package ‘terra’ ... ** using staged installation configure: CC: gcc configure: CXX: g++ -std=gnu++11 checking for gdal-config... /wsu/el7/gnu7/gdal/3.0.1/bin/gdal-config checking gdal-config usability... yes configure: GDAL: 3.0.1 checking GDAL version >= 2.0.1... yes checking for gcc... gcc 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 accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/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: /wsu/el7/gnu7/gdal/3.0.1/share/gdal/pcs.csv readable... no checking GDAL: checking whether PROJ is available for linking:... yes checking GDAL: checking whether PROJ is available fur running:... yes configure: GDAL: 3.0.1 checking proj.h usability... no checking proj.h presence... no checking for proj.h... no 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 ‘terra’
  • removing ‘/wsu/el7/gnu7/R/R-4.1.0/lib64/R/library/terra’

Any help is greatly appreciated :)

sabdall33 avatar Jul 19 '22 20:07 sabdall33

Closing as there have not been any updates for a while.

rhijmans avatar Sep 02 '22 01:09 rhijmans