isciences / exactextract

Fast and accurate raster zonal statistics
Apache License 2.0
255 stars 33 forks source link

Build error on OSX 10.12.6 #5

Closed tomplex closed 5 years ago

tomplex commented 5 years ago

I'm trying to install this library on OSX. geos & gdal are already installed, but I'm getting a linker error on make:

Undefined symbols for architecture x86_64:
  "_GEOSCoordSeq_create", referenced from:
      exactextract::FloodFill::cell_is_inside(unsigned long, unsigned long) const in floodfill.cpp.o
      exactextract::geos_make_box_polygon(double, double, double, double) in geos_utils.cpp.o
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSCoordSeq_destroy", referenced from:
      exactextract::FloodFill::cell_is_inside(unsigned long, unsigned long) const in floodfill.cpp.o
      exactextract::geos_make_box_polygon(double, double, double, double) in geos_utils.cpp.o
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSCoordSeq_getSize", referenced from:
      exactextract::read(GEOSCoordSeq_t const*) in geos_utils.cpp.o
      exactextract::initial_segment_orientation(GEOSCoordSeq_t const*) in geos_utils.cpp.o
      exactextract::RasterCellIntersection::process_ring(GEOSGeom_t const*, bool) in raster_cell_intersection.cpp.o
  "_GEOSCoordSeq_getX", referenced from:
      exactextract::geos_get_box(GEOSGeom_t const*) in geos_utils.cpp.o
      exactextract::read(GEOSCoordSeq_t const*) in geos_utils.cpp.o
      exactextract::initial_segment_orientation(GEOSCoordSeq_t const*) in geos_utils.cpp.o
      exactextract::RasterCellIntersection::process_ring(GEOSGeom_t const*, bool) in raster_cell_intersection.cpp.o
  "_GEOSCoordSeq_getY", referenced from:
      exactextract::geos_get_box(GEOSGeom_t const*) in geos_utils.cpp.o
      exactextract::read(GEOSCoordSeq_t const*) in geos_utils.cpp.o
      exactextract::initial_segment_orientation(GEOSCoordSeq_t const*) in geos_utils.cpp.o
      exactextract::RasterCellIntersection::process_ring(GEOSGeom_t const*, bool) in raster_cell_intersection.cpp.o
  "_GEOSCoordSeq_setX", referenced from:
      exactextract::FloodFill::cell_is_inside(unsigned long, unsigned long) const in floodfill.cpp.o
      exactextract::geos_make_box_polygon(double, double, double, double) in geos_utils.cpp.o
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSCoordSeq_setY", referenced from:
      exactextract::FloodFill::cell_is_inside(unsigned long, unsigned long) const in floodfill.cpp.o
      exactextract::geos_make_box_polygon(double, double, double, double) in geos_utils.cpp.o
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSEnvelope", referenced from:
      exactextract::geos_get_box(GEOSGeom_t const*) in geos_utils.cpp.o
  "_GEOSGeomGetX", referenced from:
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSGeomGetY", referenced from:
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSGeomTypeId", referenced from:
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
      exactextract::RasterCellIntersection::process(GEOSGeom_t const*) in raster_cell_intersection.cpp.o
  "_GEOSGeom_clone", referenced from:
      exactextract::FloodFill::FloodFill(GEOSGeom_t const*, exactextract::Grid<exactextract::bounded_extent> const&) in floodfill.cpp.o
  "_GEOSGeom_createLineString", referenced from:
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSGeom_createLinearRing", referenced from:
      exactextract::geos_make_box_polygon(double, double, double, double) in geos_utils.cpp.o
  "_GEOSGeom_createPoint", referenced from:
      exactextract::FloodFill::cell_is_inside(unsigned long, unsigned long) const in floodfill.cpp.o
  "_GEOSGeom_createPolygon", referenced from:
      exactextract::FloodFill::FloodFill(GEOSGeom_t const*, exactextract::Grid<exactextract::bounded_extent> const&) in floodfill.cpp.o
      exactextract::geos_make_box_polygon(double, double, double, double) in geos_utils.cpp.o
  "_GEOSGeom_destroy", referenced from:
      exactextract::FloodFill::FloodFill(GEOSGeom_t const*, exactextract::Grid<exactextract::bounded_extent> const&) in floodfill.cpp.o
      exactextract::FloodFill::cell_is_inside(unsigned long, unsigned long) const in floodfill.cpp.o
      exactextract::geos_make_box_polygon(double, double, double, double) in geos_utils.cpp.o
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
      exactextract::geos_get_box(GEOSGeom_t const*) in geos_utils.cpp.o
  "_GEOSGeom_getCoordSeq", referenced from:
      exactextract::geos_get_box(GEOSGeom_t const*) in geos_utils.cpp.o
      exactextract::RasterCellIntersection::process_ring(GEOSGeom_t const*, bool) in raster_cell_intersection.cpp.o
  "_GEOSGetExteriorRing", referenced from:
      exactextract::geos_get_box(GEOSGeom_t const*) in geos_utils.cpp.o
      exactextract::RasterCellIntersection::process(GEOSGeom_t const*) in raster_cell_intersection.cpp.o
  "_GEOSGetGeometryN", referenced from:
      exactextract::RasterCellIntersection::process(GEOSGeom_t const*) in raster_cell_intersection.cpp.o
  "_GEOSGetInteriorRingN", referenced from:
      exactextract::RasterCellIntersection::process(GEOSGeom_t const*) in raster_cell_intersection.cpp.o
  "_GEOSGetNumGeometries", referenced from:
      exactextract::RasterCellIntersection::process(GEOSGeom_t const*) in raster_cell_intersection.cpp.o
  "_GEOSGetNumInteriorRings", referenced from:
      exactextract::RasterCellIntersection::process(GEOSGeom_t const*) in raster_cell_intersection.cpp.o
  "_GEOSIntersection", referenced from:
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
  "_GEOSOrientationIndex", referenced from:
      exactextract::geos_is_ccw(GEOSCoordSeq_t const*) in geos_utils.cpp.o
  "_GEOSPrepare", referenced from:
      exactextract::FloodFill::FloodFill(GEOSGeom_t const*, exactextract::Grid<exactextract::bounded_extent> const&) in floodfill.cpp.o
  "_GEOSPreparedContains", referenced from:
      exactextract::FloodFill::cell_is_inside(unsigned long, unsigned long) const in floodfill.cpp.o
  "_GEOSPreparedGeom_destroy", referenced from:
      exactextract::FloodFill::FloodFill(GEOSGeom_t const*, exactextract::Grid<exactextract::bounded_extent> const&) in floodfill.cpp.o
  "_GEOSisEmpty", referenced from:
      exactextract::segment_intersection(exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate const&, exactextract::Coordinate&) in geos_utils.cpp.o
      exactextract::RasterCellIntersection::RasterCellIntersection(exactextract::Grid<exactextract::bounded_extent> const&, GEOSGeom_t const*) in raster_cell_intersection.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libexactextract.dylib] Error 1
make[1]: *** [CMakeFiles/exactextract_SHARED.dir/all] Error 2
make: *** [all] Error 2

When running the cmake -DCMAKE_BUILD_TYPE=Release .. command, it is able to find the GEOS and GDAL libraries:

➙ cmake -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GEOS: /Library/Frameworks/GEOS.framework
-- Found GDAL: /Library/Frameworks/GDAL.framework/Versions/2.1/unix/lib/libgdal.dylib

Any idea what might be causing this?

dbaston commented 5 years ago

I don't have access to OS X to explore this, but it seems a little suspicious that the cmake output shows a path to a dylib for GDAL but not for GEOS.

tomplex commented 5 years ago

Interesting. I have a libgeos.dylib and libgeos_c.dylib in my /Library/Frameworks/GEOS.framework/Versions/3/unix/lib directory.

dbaston commented 5 years ago

The _c one is what it should be linking against.

tomplex commented 5 years ago

I'm pretty unfamiliar with the guts of this sort of thing, any recommendations as to how to make that happen, or what to search for?

dbaston commented 5 years ago

You could do make exactextract_bin VERBOSE=1 and see what the linker invocation actually looks like, and then try tweaking that command. I'm guessing you'll see that the libgeos_c.dylib file isn't being passed to the linker.

If this is the case, you'd want to poke around in FindGEOS.cmake and see if you can find out why. It's possible that the issue has come up in a large project like QGIS and been fixed there.

tomplex commented 5 years ago

Thanks, Dan. Will dig deeper when I get a chance and let you know how it turns out.

dbaston commented 5 years ago

Fixed by 81f7a423055f0067fe7f276c91bc2d57d1b63daa