gdal-config not found while installing packages, Mac M1 Ventura

I am trying to install some packages to work with spatial data such as sf, stars, rgdal, on a Mac Book Air M1 with Ventura.
To do so, I need to have gdal installed to my compute, which I have. My problem is that when I try to install a library (see example with sf here below), the gdal-config file is not found.
But I have it on my computer, so my question is :
Is there a way to indicate the path to R to find that file ?

I tried to to uninstall and reinstall gdal with homebrew, I have proj that is also a dependency rightly installed.
I need to install from sf from sources as it is needed to install the stars package.

Any help is welcome.

Decline the option to install from source anytime compilation fails.

I need to install from sources as this version is needed for the stars package...

This is my Path :

(base) @MacBook-Air ~ % echo $PATH

gdal-config is in /opt/homebrew/Cellar/gdal/3.6.2_2/bin. Do I need to extend the search further maybe ?

Ah, 1.09.

Should be found with that PATH order. If you’re trying this from the IDE without a .Renviron dot file, switch to iTerm2 or your favorite term app, fire up R and install from there.

It found gdal-config this way but I have another error now.
Do you have any idea ?

> install.packages("sf")

--- SVP sélectionner un miroir CRAN pour cette session ---

Fontconfig warning: ignoring UTF-8: not a valid region tag

Une version binaire est disponible mais la version du source est plus


binary source needs_compilation

sf 1.0-7 1.0-9 TRUE

Вы хотите установить из исходников пакет, который нуждается в компиляции? (Yes/no/cancel) Yes

installation du package source ‘sf’

essai de l'URL ''

Content type 'application/octet-stream' length 3480774 bytes (3.3 MB)


downloaded 3.3 MB

* installing *source* package ‘sf’ ...

** package ‘sf’ correctement décompressé et sommes MD5 vérifiées

** using staged installation

configure: CC: clang -mmacosx-version-min=10.13

configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++11

checking for gdal-config... /opt/homebrew/bin/gdal-config

checking gdal-config usability... yes

configure: GDAL: 3.6.2

checking GDAL version >= 2.0.1... yes

checking for gcc... clang -mmacosx-version-min=10.13

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 the compiler supports GNU C... yes

checking whether clang -mmacosx-version-min=10.13 accepts -g... yes

checking for clang -mmacosx-version-min=10.13 option to enable C11 features... none needed

checking for stdio.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for strings.h... yes

checking for sys/stat.h... yes

checking for sys/types.h... yes

checking for unistd.h... yes

checking for gdal.h... yes

checking GDAL: linking with --libs only... no

checking GDAL: linking with --libs and --dep-libs... no

ld: warning: ignoring file /opt/homebrew/Cellar/gdal/3.6.2_2/lib/libgdal.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

Undefined symbols for architecture x86_64:

"_GDALAllRegister", referenced from:

_main in gdal_test-4d19fe.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

ld: library not found for -lodbcinst

clang: error: linker command failed with exit code 1 (use -v to see invocation)

configure: Install failure: compilation and/or linkage problems.

configure: error: GDALAllRegister not found in libgdal.

ERROR: configuration failed for package ‘sf’

* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf’

* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf’

I understand that I don't have gdal for macOS-arm64 (M1) but for macOS-x86_64 (Intel).

I solve it by reinstalling R and R Studio to their latest version, thanks for your help !

1 Like

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.