How to fix "configure: error: proj_api.h not found in standard or given locations." when installing 'terra' package on linux OS?

Hello! I am new to programming in R and I am trying to run an R script that needs to install the dependency terra on Linux OS to install the raster package. I am given the following output:

Installing package into ‘/scratch/gwarne/PEI_test/Rlibs’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/src/contrib/terra_1.6-17.tar.gz'
Content type 'application/x-gzip' length 698382 bytes (682 KB)
==================================================
downloaded 682 KB

* installing *source* package ‘terra’ ...
** package ‘terra’ successfully unpacked and MD5 sums checked
** using staged installation
configure: WARNING: unrecognized options: --with-proj_api.h
configure: CC: gcc
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.0.4
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: /usr/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.4
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 ‘/scratch/gwarne/PEI_test/Rlibs/terra’

Does anyone know where proj_api.h is supposed to be located to correctly configure the package 'terra'?

You are missing the PROJ system library, terra requires PROJ (>= 4.9.3), and the specific command to install it depends on the Linux distribution you are using.

If you are on Ubuntu, you can install it from a system terminal with this command

sudo apt install libproj-dev 

It is working now, thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.