r-spatial / sf

Simple Features for R
https://r-spatial.github.io/sf/
Other
1.33k stars 294 forks source link

macOS install instructions #1401

Closed pat-s closed 3 years ago

pat-s commented 4 years ago

I am able to install {sf} 0.9-3 from source on macOS without the need for custom configure.args.

With

on R 4.0.0 on latest macOS 10.15.4

proj, gdal and geos installed (and linked) via brew. No custom Makevars set. Might be worth updating the install instructions in the README?

Details ```r configure: CC: ccache clang configure: CXX: ccache clang++ -std=gnu++11 checking for gdal-config... /usr/local/bin/gdal-config checking gdal-config usability... yes configure: GDAL: 2.4.4 checking GDAL version >= 2.0.1... yes checking for gcc... ccache 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 ccache clang accepts -g... yes checking for ccache clang option to accept ISO C89... none needed checking how to run the C preprocessor... ccache 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... 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/Cellar/gdal/2.4.4_6/share/gdal/pcs.csv readable... yes checking GDAL: checking whether PROJ is available for linking:... yes checking GDAL: checking whether PROJ is available fur running:... yes configure: GDAL: 2.4.4 configure: pkg-config proj exists, will use it configure: using proj.h. configure: PROJ: 7.0.1 checking PROJ: checking whether PROJ and sqlite3 are available for linking:... yes checking for geos-config... /usr/local/bin/geos-config checking geos-config usability... yes configure: GEOS: 3.8.1 checking GEOS version >= 3.4.0... yes checking geos_c.h usability... yes checking geos_c.h presence... yes checking for geos_c.h... yes checking geos: linking with -L/usr/local/Cellar/geos/3.8.1_1/lib -lgeos_c... yes configure: Package CPP flags: -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include configure: Package LIBS: -L/usr/local/Cellar/proj/7.0.1/lib -lproj -L/usr/local/Cellar/gdal/2.4.4_6/lib -lgdal -L/usr/local/Cellar/geos/3.8.1_1/lib -lgeos_c configure: creating ./config.status config.status: creating src/Makevars ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c bbox.cpp -o bbox.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c gdal.cpp -o gdal.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c gdal_geom.cpp -o gdal_geom.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c gdal_read.cpp -o gdal_read.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c gdal_utils.cpp -o gdal_utils.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c gdal_write.cpp -o gdal_write.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c geos.cpp -o geos.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c hex.cpp -o hex.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c ops.cpp -o ops.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c polygonize.cpp -o polygonize.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c proj.cpp -o proj.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c proj_info.cpp -o proj_info.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c raster2sf.cpp -o raster2sf.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c sfg.cpp -o sfg.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c signed_area.cpp -o signed_area.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c stars.cpp -o stars.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c wkb.cpp -o wkb.o ccache clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/Cellar/proj/7.0.1/include -DHAVE_PROJ_H -I/usr/local/Cellar/gdal/2.4.4_6/include -I/usr/local/Cellar/geos/3.8.1_1/include -I'/Users/pjs/Library/R/4.0/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c zm_range.cpp -o zm_range.o ccache clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o sf.so RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_utils.o gdal_write.o geos.o hex.o ops.o polygonize.o proj.o proj_info.o raster2sf.o sfg.o signed_area.o stars.o wkb.o zm_range.o -L/usr/local/Cellar/proj/7.0.1/lib -lproj -L/usr/local/Cellar/gdal/2.4.4_6/lib -lgdal -L/usr/local/Cellar/geos/3.8.1_1/lib -lgeos_c -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation in method for ‘dbWriteTable’ with signature ‘"PostgreSQLConnection","character","sf"’: no definition for class “PostgreSQLConnection” in method for ‘dbDataType’ with signature ‘"PostgreSQLConnection","sf"’: no definition for class “PostgreSQLConnection” in method for ‘coerce’ with signature ‘"Spatial","sf"’: no definition for class “Spatial” in method for ‘coerce’ with signature ‘"Spatial","sfc"’: no definition for class “Spatial” in method for ‘coerce’ with signature ‘"sf","Spatial"’: no definition for class “Spatial” in method for ‘coerce’ with signature ‘"sfc","Spatial"’: no definition for class “Spatial” in method for ‘coerce’ with signature ‘"XY","Spatial"’: no definition for class “Spatial” in method for ‘coerce’ with signature ‘"crs","CRS"’: no definition for class “CRS” ```
rsbivand commented 4 years ago

If you use PROJ >= 6, you should also use GDAL >= 3. It doesn't make sense to go beyond PROJ 5 for GDAL 2, which doesn't bring the benefits of the GDAL barn-raising project.

pat-s commented 4 years ago

User relying on homebrew-core on macOS do not have a version choice here.

One could use the osgeo4mac tap which comes with osgeo-gdal and osgeo-proj but robustness and maintenance of these formulas vary over time (judging from my personal experience and talking to the devs).

If you use PROJ >= 6, you should also use GDAL >= 3.

This could go into the README as a separate info. This PR just addresses the fact that configure.args is not (anymore) needed for installing {sf}.

In the not so far future, homebrew core will also update to gdal 3 anyways.

ateucher commented 4 years ago

That's good to hear @pat-s, thanks for the update. I agree - the osgeo4mac tap, while in principle seems like a great idea, has been pretty unreliable and I've stopped using it.

LDalby commented 4 years ago

Gdal was just updated to 3.1 on Homebrew, so I just installed sf from source. I had to adjust the install.packages() call to use type = "source" to actually compile it. Using the command from the install instructions didn't trigger a source installation. In a addition I had to change the path to proj.

The working call for me:

install.packages("sf", configure.args = "--with-proj-lib=/usr/local/Cellar/proj", type = "source")

Which results in sf linking to GEOS 3.8.1, GDAL 3.1.0, PROJ 7.0.1

I'll admit that I'm not sure if I at some point made changes to where homebrew install stuff since my system apparently refers to /usr/local/Cellar/ and not /usr/local/lib/. So that part might needs to remain as is, but I believe that the type argument needs to be set to "source" in the instructions.

MacOS 10.14.6, R 4.0.1

ateucher commented 4 years ago

As I mentioned in #1430, I also installed sf from source using homebrew core gdal/proj/geos (not the osgeo tap), and didn't need an --configure.args etc. Just install.packages("sf", type = "source")

pat-s commented 4 years ago

@ateucher This works for quite some time already, I think since proj 7.0.1 arrived in homebrew-core. AFAIK the workaround was needed for PROJ 7.0.0.

GDAL2 was never (?) an issue in {sf}.

ateucher commented 4 years ago

You're right @pat-s - I was just responding to to @LDalby to say that it's not necessary to specify --configure.args (as you say, since PROJ 7.0.1).