Error: Gdal-Config Not Found While Installing R Dependent Packages Whereas Gdal Is Installed

Error: gdal-config not found while installing R dependent packages whereas gdal is installed

You need the -dev package with headers and shared library links for development besides the normal package for deployment. Two different use cases as far as the distro is concerned.

On my distribution:

edd@max:/tmp$ dpkg -l | grep gdal | cut -c-72
ii libgdal1-1.7.0 1.7.3-6ubuntu3
ii libgdal1-dev 1.7.3-6ubuntu3
edd@max:/tmp$

and R CMD INSTALL rgdal_0.7-8.tar.gz works just fine as you would expect from a CRAN package given all the build-time checks at CRAN.

Update late 2016: As @JoshO'Brien points out in the comment

Minor update: Here in 2016, running Ubuntu 14.04.2, libgdal1h seems to
have replaced libgdal1(though libgdal1-dev is still needed). At least
I get an error to that effect when I attempted to apt-get install libgdal1

For Ubuntu 16.04 the corresponding line would be

sudo apt-get install libgdal1i

Such renaming of upstream libraries is common; something such as apt-cache search libgdal can help locate the current package names. The important key though is that the "abstract" development package libgdal-dev is all that is needed to build as it pulls the "concrete" current run-time package (here: libgdal1i) in via a dependency.

Ubuntu 16.04 R Installation: configure: gdal-config not found or not executable

You have to install gdal, proj & geos on your Linux system.

 sudo apt-get install libgdal1-dev gdal-bin libproj-dev proj-data proj-bin libgeos-dev

To compile yourself, see this script (backup)

Edit: For Ubuntu 18.04 Bionic or Mint 19 Tara

 sudo apt-get install libgdal-dev gdal-bin libproj-dev proj-data proj-bin libgeos-dev

updating Rgdal in R.3.5.1 C++11 dependency... although C++11 is available

In my case, the solution was to update my ~/.R/Makevars config.

  CC=clang
CXX=clang++
PKG_CFLAGS= -g -O2

I added: -std=gnu++11 to my CXX definition

  CC=clang
CXX=clang++ -std=gnu++11
PKG_CFLAGS= -g -O2

after this, the compile problems and related error no longer occur (at least in my testing so far)

Inference

The above leads to the question - Why? A new install of R 3.5.1 with rgdal does not (in my experience) exhibit the compile error, whilst the upgrade from 3.4.4 does. My sense is that an interaction exists between R and rgdal package config that causes the C++11 compile flag to be not activated. rgdal requires and uses C++11 features. See Makevar - an overview below.

Citations:

  • R Installation and Administration
  • R Using Makevars
  • How do I enable C++11 in gcc?

Compile Example:

No -std=gnu++11 flag in Makevars [Errors]

> install.packages("rgdal")
--2018-08-10 21:31:58-- https://cran.rstudio.com/src/contrib/rgdal_1.3-4.tar.gz
Resolving cran.rstudio.com (cran.rstudio.com)... 52.84.17.191
Connecting to cran.rstudio.com (cran.rstudio.com)|52.84.17.191|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1664774 (1.6M) [application/x-gzip]
Saving to: ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’

/var/folders/md/03gdc4c14z18kbqwpfh4jd 100%[============================================================================>] 1.59M --.-KB/s in 0.04s

2018-08-10 21:31:58 (35.6 MB/s) - ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’ saved [1664774/1664774]

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /Users/***/.Renv/versions/3.5.1/lib/R
configure: CC: clang
configure: CXX: clang++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/opt/gdal2/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal2/2.3.1/include/gdal.h:45:
/usr/local/Cellar/gdal2/2.3.1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal2/2.3.1/include/gdal.h:45:
/usr/local/Cellar/gdal2/2.3.1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Users/***/.Renv/versions/3.5.1/lib/R/library/rgdal’

The downloaded source packages are in
‘/private/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T/RtmpidZNr4/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rgdal") :
installation of package ‘rgdal’ had non-zero exit status

Added -std=gnu++11 to Makevars

> install.packages("rgdal")
--2018-08-10 21:34:20-- https://cran.rstudio.com/src/contrib/rgdal_1.3-4.tar.gz
Resolving cran.rstudio.com (cran.rstudio.com)... 52.84.17.191
Connecting to cran.rstudio.com (cran.rstudio.com)|52.84.17.191|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1664774 (1.6M) [application/x-gzip]
Saving to: ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’

/var/folders/md/03gdc4c14z18kbqwpfh4jd 100%[============================================================================>] 1.59M --.-KB/s in 0.04s

2018-08-10 21:34:20 (43.5 MB/s) - ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’ saved [1664774/1664774]

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /Users/***/.Renv/versions/3.5.1/lib/R
configure: CC: clang
configure: CXX: clang++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/opt/gdal2/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/local/Cellar/gdal2/2.3.1/share/gdal/pcs.csv readable... yes
configure: pkg-config proj exists, will use it
configure: PROJ version: 5.1.0
checking proj_api.h presence and usability... yes
checking PROJ version >= 4.8.0... yes
checking projects.h presence and usability... yes
checking PROJ.4: epsg found and readable... yes
checking PROJ.4: conus found and readable... yes
configure: Package CPP flags: -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include
configure: Package LIBS: -L/usr/local/Cellar/gdal2/2.3.1/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c OGR_write.cpp -o OGR_write.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c gdal-bindings.cpp -o gdal-bindings.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c init.c -o init.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c inverser.c -o inverser.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c local_stubs.c -o local_stubs.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogr_geom.cpp -o ogr_geom.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c ogr_polygons.c -o ogr_polygons.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogr_proj.cpp -o ogr_proj.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogrdrivers.cpp -o ogrdrivers.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogrsource.cpp -o ogrsource.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip@2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c projectit.cpp -o projectit.o
g++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/***/.Renv/versions/3.5.1/lib/R/lib -L/usr/local/opt/gdal2/lib -L/usr/local/opt/liblas-gdal2/lib -L/usr/local/opt/laszip@2.2/lib -L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib -o rgdal.so OGR_write.o gdal-bindings.o init.o inverser.o local_stubs.o ogr_geom.o ogr_polygons.o ogr_proj.o ogrdrivers.o ogrsource.o projectit.o -L/usr/local/Cellar/gdal2/2.3.1/lib -lgdal -lproj -L/Users/***/.Renv/versions/3.5.1/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/***/.Renv/versions/3.5.1/lib/R/library/rgdal/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (rgdal)

The downloaded source packages are in
‘/private/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T/RtmpidZNr4/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

MakeVars - An Overview:

Makevars is a makefile that overrides the default makefile generated by R (which is located at file.path(R.home("etc"), "Makeconf")). This allows you to take advantage of R’s default behaviour while being able to set the flags you need. These are the most commonly used flags:

  • PKG_LIBS
    Linker flags. A common use is PKG_LIBS = $(BLAS_LIBS). This allows you to use the same BLAS library as R.

  • PKG_CFLAGS and PKG_CXXFLAGS
    C and C++ flags. Most commonly used to set define directives with -D.

PKG_CPPFLAGS
Preprocessor flags (not C++ flags!). Most commonly used to set include directories with -I. Any package listed in the LinkingTo field in the DESCRIPTION will be automatically included—you do not need to explicitly add it.

I hope the above helps point you in the direction of a solution.

rgdal package installation

I f you look at the package page on CRAN, you will see the following :

SystemRequirements: for building from source: GDAL >= 1.7.1 library
from http://trac.osgeo.org/gdal/wiki/DownloadSource and PROJ.4 (proj >= 4.4.9) from http://trac.osgeo.org/proj/; GDAL OSX frameworks built by William Kyngesburye at http://www.kyngchaos.com/ may be used for
source installs on OSX.

As you seem to be under Linux, you always build package from source, so you will have to install the corresponding libraries on your system. If you are under Mint, Ubuntu or another Debian derivative, you can do :

$ sudo apt-get install libgdal1-dev libproj-dev

One tip that can be useful, still under a Debian based system, is to install the apt-file package and run :

$ sudo apt-file update

Then, when you get an error such as :

configure: error: proj_api.h not found in standard or given locations.

You can use the following command to find which package you must install to get the missing file :

$ apt-file search proj_api.h
libproj-dev: /usr/include/proj_api.h

Error while installing gdal on Azure Databricks

There are different methods to install packages in Azure Databricks:

Method1: Using libraries

To make third-party or locally-built code available to notebooks and jobs running on your clusters, you can install a library. Libraries can be written in Python, Java, Scala, and R. You can upload Java, Scala, and Python libraries and point to external packages in PyPI, Maven, and CRAN repositories.

Steps to install third party libraries:

Step1: Create Databricks Cluster.

Step2: Select the cluster created.

Step3: Select Libraries => Install New => Select Library Source = "Maven" => Coordinates => Search Packages => Select Maven Central => Search for the package required. Example: (GDAL) => Select the version (3.0.0) required => Install

Sample Image

Method2: Using Cluster-scoped init scripts

Cluster-scoped init scripts are init scripts defined in a cluster configuration. Cluster-scoped init scripts apply to both clusters you create and those created to run jobs. Since the scripts are part of the cluster configuration, cluster access control lets you control who can change the scripts.

Step1: Add the DBFS path dbfs:/databricks/scripts/gdal_install.sh to the cluster init scripts

# --- Run 1x to setup the init script. ---
# Restart cluster after running.
dbutils.fs.put("/databricks/scripts/gdal_install.sh","""
#!/bin/bash
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install -y cmake gdal-bin libgdal-dev python3-gdal""",
True)

Step2: Restart the cluster after running step1 for the first time.

For more details, refer "RasterFrames Notebook".

Hope this helps. Do let us know if you any further queries.

How to fix ERROR 1: Cannot get geotransform in GDAL

You can't "fix it" short of properly georeferencing your dataset.

The error means that your dataset lacks georeferencing information so GDAL is unable to convert the WGS84 coordinates to pixel coordinates.



Related Topics



Leave a reply



Submit