Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install `proj4` package because libproj and/or proj_api.h not found in standard search locations

Tags:

r

r-package

proj

I want to install ggalt package which needs proj4 package installed, but when I install proj4 it throws an error libproj and/or proj_api.h not found in standard search locations.

My computer is Mac, and I have installed PROJ.4 using brew install proj, and the version of R is 3.6.0_2. I searched on the Internet for this problem but didn't find a method to solve it. I'm not a coder and just begin to learn R, so I don't know how to do now.

The error shows as below:

* installing *source* package ‘proj4’ ...
** package ‘proj4’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... clang
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 clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -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... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
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 proj_api.h usability... no
checking proj_api.h presence... no
checking for proj_api.h... no
checking for pj_init_plus in -lproj... yes
configure: error: libproj and/or proj_api.h not found in standard search locations.

*** Install PROJ.4 and if necessary set PKG_CPPFLAGS/PKG_LIBS accordingly.
ERROR: configuration failed for package ‘proj4’
* removing ‘/usr/local/lib/R/3.6/site-library/proj4’

The downloaded source packages are in
    ‘/private/var/folders/sn/1d6n55qs0zl522kcc769jq5h0000gn/T/RtmpNOkU64/downloaded_packages’
like image 407
juby Avatar asked May 25 '19 11:05

juby


2 Answers

I'm running Pop!_OS 20.04 (Ubuntu fork) and ran into the same problem with proj4 not installing (R 3.6.3). I don't believe libproj was installed yet. I was able to do that manually via the terminal with this command:

sudo apt-get install libproj-dev

I restarted R and was able to install proj4.

like image 105
DirtStats Avatar answered Sep 30 '22 04:09

DirtStats


I got also this annoying problem. I was able to build it manually - but at the moment it's a dirty hack. Note I'm not a C programmer so it will not be fixed.

I found at the top of proj_api.h:

#ifndef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
#error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
#endif

I figured I could insert

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H

before line 7 in src/p4.c and line 1462 of configure of the package source (in both cases just before #include).

I suppose one could also remove the section from proj_api.h - however I have not the slightest clue if it might break anything.

like image 42
bdecaf Avatar answered Sep 30 '22 05:09

bdecaf