Sf: proj_api.h not found in standard or given locations

Created on 25 Jun 2019  Â·  11Comments  Â·  Source: r-spatial/sf

Centos7 OS
R version 3.6.0
Proj4 6.1.9 installed to default /usr/local location with ./configure, make, sudo make install
GDAL 3.0.0 installed to default /usr/local location with ./configure, make, sudo make install
GEOS 3.7.2 installed to default /usr/local location with ./configure, make, sudo make install
/etc/ld.so.conf.d/libgdal-x86_64.conf contains /usr/local/lib
then sudo ldconfig

remotes::install_github("r-spatial/sf", configure.args = "--with-gdal-config=/usr/local/bin/gdal-config --with-geos-config=/usr/local/bin/geos-config --with-proj-include=/usr/local/include/ --with-proj-lib=/usr/local/lib/")

Downloading GitHub repo r-spatial/sf@masterroj-lib=/usr/local/lib/")
Running R CMD build...

  • checking for file ‘/tmp/Rtmp7lzWH1/remotesd64758beac60/r-spatial-sf-ee35c42/DESCRIPTION’ ... OK
  • preparing ‘sf’:
  • checking DESCRIPTION meta-information ... OK
  • cleaning src
  • running ‘cleanup’
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
  • building ‘sf_0.7-5.tar.gz’
    Installing package into ‘/usr/lib64/R/library’
    (as ‘lib’ is unspecified)
  • installing source package ‘sf’ ...
    ** using staged installation
    configure: CC: gcc -m64 -std=gnu99
    configure: CXX: g++ -m64 -std=gnu++11
    configure: gdal-config set to /usr/local/bin/gdal-config
    checking gdal-config exists... yes
    checking gdal-config executable... yes
    checking gdal-config usability... yes
    configure: GDAL: 3.0.0
    checking GDAL version >= 2.0.1... yes
    checking for gcc... gcc -m64 -std=gnu99
    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 -m64 -std=gnu99 accepts -g... yes
    checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
    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: /usr/local/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
    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 ‘sf’
  • removing ‘/usr/lib64/R/library/sf’
    Error in i.p(...) :
    (converted from warning) installation of package ‘/tmp/Rtmp7lzWH1/filed6474cb52a8/sf_0.7-5.tar.gz’ had non-zero exit status

I'm stumped! I see proj_api.h here: /usr/local/include/proj_api.h

Suggestions please?

Most helpful comment

Interesting, I had thought R picked up my Bash environment variables by default but it doesn't.
Doing the following led me to build 'sf' successfully:

> print(Sys.setenv(PKG_CONFIG_PATH = "/usr/local/lib/pkgconfig/"))

Thanks for your patience and help!

All 11 comments

Proj4 6.1.9 does not exist.

What I see is

checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: pkg-config proj exists, will use it
checking proj.h usability... yes
checking proj.h presence... yes
checking for proj.h... yes
...

Is it possible that you don't have e.g. this working:

root@43c5e412d3ee:/# pkg-config proj --libs
-L/usr/local/lib -lproj

please check & report back.

Sorry, I meant Proj4 version 6.1.0
Is this on one line?
pkg-config proj --libs -L/usr/local/lib -lproj
If so, it errors in Centos:

pkg-config --libs -L/usr/local/lib -lproj
Unknown option -L/usr/local/lib

Not one line, run:

pkg-config --libs

with

-L/usr/local/lib -lproj

the expected output.

Okay, thanks. Here's the output:

# pkg-config --libs
Must specify package names on the command line

No: please try

pkg-config proj --libs
# pkg-config proj --libs
Package proj was not found in the pkg-config search path.
Perhaps you should add the directory containing `proj.pc'
to the PKG_CONFIG_PATH environment variable
No package 'proj' found
# pkg-config proj --libs
Package proj was not found in the pkg-config search path.
Perhaps you should add the directory containing `proj.pc'
to the PKG_CONFIG_PATH environment variable
No package 'proj' found

Which is weird because:

# echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig/
# ls $PKG_CONFIG_PATH
gdal.pc  proj.pc

Well, at least it gives you a direction to search for a solution.

Interesting, I had thought R picked up my Bash environment variables by default but it doesn't.
Doing the following led me to build 'sf' successfully:

> print(Sys.setenv(PKG_CONFIG_PATH = "/usr/local/lib/pkgconfig/"))

Thanks for your patience and help!

R picks up environment variables, when they are properly set in the environment in which R is started.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

duleise picture duleise  Â·  3Comments

kendonB picture kendonB  Â·  4Comments

kendonB picture kendonB  Â·  4Comments

matthewpaulking picture matthewpaulking  Â·  4Comments

kendonB picture kendonB  Â·  3Comments