isciences / exactextractr

R package for fast and accurate raster zonal statistics
https://isciences.gitlab.io/exactextractr/
278 stars 26 forks source link

Problem installing on MacOS #3

Closed tzachiraz closed 5 years ago

tzachiraz commented 6 years ago

I tried to install and I get the following error msg:

exact_extract.cpp:18:10: fatal error: 'geos_c.h' file not found

include

     ^~~~~~~~~~

1 error generated. make: *** [exact_extract.o] Error 1 ERROR: compilation failed for package ‘exactextractr’

Any idea what's the problem and how to fix it? Thanks!

dbaston commented 6 years ago

Hi @tzachiraz . You're getting this error because you don't have the GEOS library installed, or it isn't visible to your compiler. It looks like you can install it with Homebrew. (Sorry, I don't have access to a Mac to test)

tzachiraz commented 6 years ago

Thanks for your response @dbaston ! I thought that since other packages I use link to GEOS that can't be the problem.

library(sf) Linking to GEOS 3.6.1, GDAL 2.1.3, proj.4 4.9.3

Maybe I'm missing something...

axlehner commented 5 years ago

I have the same issue. Also on a Mac. sf and GEOS work fine. Probably some paths are messed up?

dbaston commented 5 years ago

Not sure. I now have access to a Mac and was able to install without issue.

axlehner commented 5 years ago

to be on the safe side with messed up paths etc. I installed GEOS by hand from this source: http://www.kyngchaos.com/software/frameworks/, restarted R session and tried to install. Same error again...

dbaston commented 5 years ago

You can see what paths R is looking in by looking at the command used to run the compiler. On mine, it looks like this:

clang++ -std=gnu++14 -I"/usr/local/Cellar/r/3.5.1/lib/R/include" -DNDEBUG -I"/usr/local/lib/R/3.5/site-library/Rcpp/include" -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -fPIC -g -O2 -c exactextract/src/area.cpp -o exactextract/src/area.o

On the system I'm testing with, geos_c.h (installed by homebrew) is located in /usr/local/include. It looks like you're using a GEOS framework instead, and R isn't looking in the framework path.

dbaston commented 5 years ago

I've removed my homebrew install of geos and installed the Kyngchaos distribution of the framework, and I'm seeing the same issue as you are. Since R is not including frameworks in the include directories, it looks like I may have to switch to an autotools build (like rgeos and sf use) to make this work on MacOS framework installs.

In the meantime, install GEOS with homebrew if you want to use this package.

dbaston commented 5 years ago

Closed by accident, reopening.

axlehner commented 5 years ago

OK, thanks a lot for your help!

dbaston commented 5 years ago

@axlehner Give this a try if you like:

install_github('isciences/exactextractr', configure.args=c(exactextractr="--with-geos-config=/Library/Frameworks/GEOS.framework/unix/bin/geos-config"))

The path to geos-config may vary on your system, but this is where the Kyngchaos distribution ended up on mine.

dbaston commented 5 years ago

I think this has been resolved; please reopen if the install_github command above doesn't work.

mabesa commented 2 years ago

Hi @dbaston We use exactextractr in a package for preparation of data for hydrological modelling riversCentralAsia (we love it's speed by the way!). This is just a notice: Some of the people running Mac OS have trouble with the automatic installation of exactextractr. It seems to be the same as above. Here's the message they get:

The installation works for them if they install from the binary. Many greetings