isciences / exactextract

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

Error compiling in macos - 'geos_c.h' not found #30

Closed aldotapia closed 2 years ago

aldotapia commented 2 years ago

Hi! I'm trying to install exactextract after installing and checking the dependencies and I can't build it. I get this error every single time:

(ee) aldotapia@MacBook-Aldo cmake-build-release % make
[  3%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/area.cpp.o
[  6%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/box.cpp.o
[  9%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o
In file included from /Users/aldotapia/exactextract/src/cell.cpp:20:
/Users/aldotapia/exactextract/src/geos_utils.h:24:10: fatal error: 'geos_c.h'
      file not found
#include <geos_c.h>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o] Error 1
make[1]: *** [CMakeFiles/exactextract_OBJ.dir/all] Error 2
make: *** [all] Error 2

Versions of GEOS and GDAL:

(ee) aldotapia@MacBook-Aldo cmake-build-release % geos-config --version
3.10.2
(ee) aldotapia@MacBook-Aldo cmake-build-release % gdalinfo --version
GDAL 3.4.2, released 2022/03/08

I have installed geos with conda install -c conda-forge geos and brew install geos. I'm inside an anaconda environment, macos Monterrey 12.1

aldotapia commented 2 years ago

More info for context. geos is found after cmake-build-release % cmake -DBUILD_CLI:=OFF -DBUILD_DOC:=OFF -DCMAKE_BUILD_TYPE=Release .. command:

-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GEOS: /usr/local/Cellar/geos/3.10.2/lib/libgeos_c.dylib
-- [download 2% complete]
...
-- [download 100% complete]
-- Source version: a0997f9
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/aldotapia/exactextract/cmake-build-release

I'm totally lost, since I have geos installed

kasra-keshavarz commented 2 years ago

Same issue here

dbaston commented 2 years ago

I don't have a Mac to test this on. What happens if you add message(STATUS ${GEOS_INCLUDE_DIR} after line 24 of CMakeLists.txt. Is geos_c.h found in that directory?

kasra-keshavarz commented 2 years ago

I added your suggested statement to the CMakeLists.txt and also I tried to manually point CMake to where the libgeos_c.dylab is and it still fails:

$ cmake -DCMAKE_BUILD_TYPE=Release -DGEOS_INCLUDE_DIR=/Users/kak136/anaconda3/lib ..
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GEOS: /Users/kak136/anaconda3/lib/libgeos_c.dylib
-- /Users/kak136/anaconda3/lib
-- Found GDAL: /Users/kak136/anaconda3/lib/libgdal.dylib (found version "3.5.0") 
-- [download 1% complete]
...
-- [download 100% complete]
-- Source version: a0997f9 (dirty)
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.9.4") found components: doxygen missing components: dot
Doxygen build started
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kak136/Documents/github-repos/exactextract/cmake-build-release

$ ls -l
total 416
drwxr-xr-x   3 kak136  1008243434    96B 27 May 10:29 CLI11
-rw-r--r--   1 kak136  1008243434    19K 27 May 10:29 CMakeCache.txt
-rw-r--r--   1 kak136  1008243434    14K 27 May 10:29 CMakeDoxyfile.in
-rw-r--r--   1 kak136  1008243434    20K 27 May 10:29 CMakeDoxygenDefaults.cmake
drwxr-xr-x  19 kak136  1008243434   608B 27 May 10:29 CMakeFiles
-rw-r--r--   1 kak136  1008243434   104K 27 May 10:29 Doxyfile
-rw-r--r--   1 kak136  1008243434    42K 27 May 10:29 Makefile
drwxr-xr-x   3 kak136  1008243434    96B 27 May 10:29 catch
-rw-r--r--   1 kak136  1008243434   2.3K 27 May 10:29 cmake_install.cmake
drwxr-xr-x   3 kak136  1008243434    96B 27 May 10:29 generated

$ make
[  2%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/area.cpp.o
[  5%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/box.cpp.o
[  7%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o
In file included from /Users/kak136/Documents/github-repos/exactextract/src/cell.cpp:20:
/Users/kak136/Documents/github-repos/exactextract/src/geos_utils.h:24:10: fatal error: 'geos_c.h' file not found
#include <geos_c.h>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o] Error 1
make[1]: *** [CMakeFiles/exactextract_OBJ.dir/all] Error 2
make: *** [all] Error 2
dbaston commented 2 years ago

Is geos_c.h in /Users/kak136/anaconda3/lib? I would expect it in an include directory somewhere. (like /Users/kak136/anaconda3/include)

kasra-keshavarz commented 2 years ago

You're right - I tested again with the new path directory:

$ ll /Users/kak136/anaconda3/include/geos_c.h 
-rw-rw-r--  2 kak136  1008243434   148K 15 Jan 23:47 /Users/kak136/anaconda3/include/geos_c.h

$ cmake -DCMAKE_BUILD_TYPE=Release -DGEOS_INCLUDE_DIR=/Users/kak136/anaconda3/include ..
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GEOS: /Users/kak136/anaconda3/lib/libgeos_c.dylib
-- /Users/kak136/anaconda3/include
-- Found GDAL: /Users/kak136/anaconda3/lib/libgdal.dylib (found version "3.5.0") 
-- [download 0% complete]
...
-- [download 100% complete]
-- Source version: a0997f9 (dirty)
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.9.4") found components: doxygen missing components: dot
Doxygen build started
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kak136/Documents/github-repos/exactextract/cmake-build-release

$ make
[  2%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/area.cpp.o
[  5%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/box.cpp.o
[  7%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o
In file included from /Users/kak136/Documents/github-repos/exactextract/src/cell.cpp:20:
/Users/kak136/Documents/github-repos/exactextract/src/geos_utils.h:24:10: fatal error: 'geos_c.h' file not found
#include <geos_c.h>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o] Error 1
make[1]: *** [CMakeFiles/exactextract_OBJ.dir/all] Error 2
make: *** [all] Error 2
dbaston commented 2 years ago

make VERBOSE=1 ?

kasra-keshavarz commented 2 years ago
$ make VERBOSE=1
/usr/local/Cellar/cmake/3.23.1_1/bin/cmake -S/Users/kak136/Documents/github-repos/exactextract -B/Users/kak136/Documents/github-repos/exactextract/cmake-build-release --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.23.1_1/bin/cmake -E cmake_progress_start /Users/kak136/Documents/github-repos/exactextract/cmake-build-release/CMakeFiles /Users/kak136/Documents/github-repos/exactextract/cmake-build-release//CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/Makefile2 all
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/exactextract_OBJ.dir/build.make CMakeFiles/exactextract_OBJ.dir/depend
cd /Users/kak136/Documents/github-repos/exactextract/cmake-build-release && /usr/local/Cellar/cmake/3.23.1_1/bin/cmake -E cmake_depends "Unix Makefiles" /Users/kak136/Documents/github-repos/exactextract /Users/kak136/Documents/github-repos/exactextract /Users/kak136/Documents/github-repos/exactextract/cmake-build-release /Users/kak136/Documents/github-repos/exactextract/cmake-build-release /Users/kak136/Documents/github-repos/exactextract/cmake-build-release/CMakeFiles/exactextract_OBJ.dir/DependInfo.cmake --color=
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/exactextract_OBJ.dir/build.make CMakeFiles/exactextract_OBJ.dir/build
[  2%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/area.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++   -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -fPIC -std=c++14 -MD -MT CMakeFiles/exactextract_OBJ.dir/src/area.cpp.o -MF CMakeFiles/exactextract_OBJ.dir/src/area.cpp.o.d -o CMakeFiles/exactextract_OBJ.dir/src/area.cpp.o -c /Users/kak136/Documents/github-repos/exactextract/src/area.cpp
[  5%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/box.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++   -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -fPIC -std=c++14 -MD -MT CMakeFiles/exactextract_OBJ.dir/src/box.cpp.o -MF CMakeFiles/exactextract_OBJ.dir/src/box.cpp.o.d -o CMakeFiles/exactextract_OBJ.dir/src/box.cpp.o -c /Users/kak136/Documents/github-repos/exactextract/src/box.cpp
[  7%] Building CXX object CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++   -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -fPIC -std=c++14 -MD -MT CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o -MF CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o.d -o CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o -c /Users/kak136/Documents/github-repos/exactextract/src/cell.cpp
In file included from /Users/kak136/Documents/github-repos/exactextract/src/cell.cpp:20:
/Users/kak136/Documents/github-repos/exactextract/src/geos_utils.h:24:10: fatal error: 'geos_c.h' file not found
#include <geos_c.h>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/exactextract_OBJ.dir/src/cell.cpp.o] Error 1
make[1]: *** [CMakeFiles/exactextract_OBJ.dir/all] Error 2
make: *** [all] Error 2
dbaston commented 2 years ago

This is helpful, thanks. It looks like a side effect of https://github.com/isciences/exactextract/pull/27 is that include directories are no longer being passed to the library. I will fix this shortly.

dbaston commented 2 years ago

Should be resolved with a8016c0887bc1fe896e5bef91a673e760e99789b.

aldotapia commented 2 years ago

Thanks @dbaston. I was able to install it with success, although I don't know if the installation was correct because the function doesn't recognize my files:

(base) aldotapia@MacBook-Aldo ~ % exactextract \
  -r mod:/Users/aldotapia/camels_test/evi.tiff[1] \
  -p /Users/aldotapia/camels_test/HidroCL_boundaries_sinu.shp \
  -f gauge_id \
  -s mean(mod) \
  -o /Users/aldotapia/camels_test/ext_test.csv
zsh: no matches found: mod:/Users/aldotapia/camels_test/evi.tiff[1]

I can see the file exits in terminal with touch /Users/aldotapia/camels_test/evi.tiff

dbaston commented 2 years ago

Your shell may require quotes around some of the arguments. I updated the README to show this.

kasra-keshavarz commented 2 years ago

I can confirm the package successfully installed on my system MacOS 12.4.

aldotapia commented 2 years ago

@dbaston thank you for all your help! I installed and run successfully (with absolute paths, relative paths didn't work, but all good with that).