isciences / exactextract

Fast and accurate raster zonal statistics
Apache License 2.0
246 stars 32 forks source link

Any thoughts on how to force compilation for x86_64 on macOS? #43

Closed beaugunderson closed 11 months ago

beaugunderson commented 1 year ago

Get this when compiling:

image

I don't mind compiling for x86_64 but am unsure how to ask cmake to do so.

dbaston commented 1 year ago

This looks related to https://github.com/isciences/exactextractr/issues/79. I don't have access to a machine to troubleshoot it.

beaugunderson commented 11 months ago

I did a little more research and figured out that I can force x86_64 using this incantation:

cmake \
  -DCMAKE_OSX_ARCHITECTURES=x86_64 \
  -DCMAKE_BUILD_TYPE=Release \
  ..

The build completes but now I get this:

$ ./exactextract

dyld[57743]: Library not loaded: /usr/local/pgsql-12/lib/libpq.5.dylib
  Referenced from: <7E2C5AE7-94FF-311B-B475-92F15948B296> /Library/Frameworks/GDAL.framework/Versions/3.1/GDAL
  Reason: tried: '/libpq.5.dylib' (no such file), '/usr/local/pgsql-12/lib/libpq.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/pgsql-12/lib/libpq.5.dylib' (no such file), '/usr/local/pgsql-12/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file, not in dyld cache)
Abort trap: 6

The only usable copies of the dylib I have are installed as part of arm64 homebrew:

/opt/homebrew/Cellar/libpq/15.4/lib/libpq.5.dylib
/opt/homebrew/Cellar/postgresql@14/14.9/lib/postgresql@14/libpq.5.dylib
beaugunderson commented 11 months ago

Oh, I see what happened! I had old versions of GEOS and GDAL in /Library/Frameworks. I removed those, re-ran cmake WITHOUT specifying CMAKE_OSX_ARCHITECTURES and it picked up the homebrew versions I have installed and succeeded in building an arm64 version. Awesome!

$  ./exactextract --help

Zonal statistics using exactextract: version 0.1.0 (f14e007)
Usage: ./exactextract [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -p,--polygons TEXT REQUIRED polygon dataset
  -r,--raster TEXT ... REQUIRED
                              raster dataset
  -f,--fid TEXT REQUIRED      id from polygon dataset to retain in output
  -o,--output TEXT REQUIRED   output filename
  -s,--stat TEXT ... REQUIRED statistics
  --max-cells UINT=30         maximum number of raster cells to read in memory at once, in millions
  --strategy TEXT=feature-sequential
                              processing strategy
  --id-type TEXT              override type of id field in output
  --id-name TEXT              override name of id field in output
  --progress
  --config TEXT               Read an ini file