petere / pex

light-weight package manager for PostgreSQL
Other
98 stars 2 forks source link

proj_api.h file not found #8

Closed nurey closed 1 year ago

nurey commented 5 years ago

I'm trying to install postgis using pex and I'm getting stuck on the error below. Proj is installed from homebrew. /usr/local/include/proj_api.h is available.

---- Making all in topology
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I../liblwgeom -I../libpgcommon  -I/usr/local/Cellar/geos/3.7.1_1/include   -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2     -fPIC -I. -I./ -I/usr/local/Cellar/postgresql@9.6/9.6.11/include/server -I/usr/local/Cellar/postgresql@9.6/9.6.11/include/internal -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk   -I/usr/local/opt/gettext/include -I/usr/local/opt/openldap/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/tcl-tk/include  -c -o postgis_topology.o postgis_topology.c
In file included from postgis_topology.c:28:
In file included from ../liblwgeom/liblwgeom_internal.h:48:
../liblwgeom/liblwgeom.h:35:10: fatal error: 'proj_api.h' file not found
#include "proj_api.h"
         ^~~~~~~~~~~~
1 error generated.
make[1]: *** [postgis_topology.o] Error 1
make: *** [all] Error 1
skissane commented 5 years ago

I am getting a similar issue, slightly different error at first though. ./configure is failing for me with:

configure: error: could not find proj_api.h - you may need to specify the directory of a PROJ.4 installation using --with-projdir

I tried running ./configure manually from the build directory, it still didn't work. After reviewing config.log, I discovered that I needed CFLAGS=-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H, which gets past the above error.

After getting past that, and fixing a few other issues (not having GDAL installed, etc.). Then I got your error.

I solved it with this: PG_CPPFLAGS='-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -I/usr/local/include' CFLAGS='-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -I/usr/local/include' pex install postgis

Basically, since Homebrew installs proj in /usr/local/include, you need -I/usr/local/include. And, since the proj-api.h is deprecated in newer proj versions, you need to pass -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H. And then, finally, the PostGIS build process sometimes will respect CFLAGS, other steps ignore CFLAGS but will respect PG_CPPFLAGS. Not sure why this is, but anyway, passing both will get past your problem.

PS: After a lot of mucking around, I actually got postgis installed with pex, here are my notes in case anyone else encounters any of the same issues: https://gist.github.com/skissane/0487c097872a7f6d0dcc9bcd120c2ccd