crazycapivara / h3-r

R bindings for H3, a hierarchical hexagonal geospatial indexing system
Other
73 stars 11 forks source link

Failed to install H3 for R #35

Closed su-park closed 4 years ago

su-park commented 4 years ago

I failed to install H3 for R on my mac.

I tried to install it using devtools but got the error as follows.

I guess it occurs when I try to install h3 for C but I know no other ways to fix it.

( based on your guidance I already installed 'cmake' and 'make' before the job )

can you give me hands for this?

If you need more information for my environments let me know.

`h3_hex-ring.cpp:2:10: fatal error: 'h3/h3api.h' file not found

include <h3/h3api.h>

     ^~~~~~~~~~~~

1 error generated. make: *** [h3_hex-ring.o] Error 1 ERROR: compilation failed for package ‘h3’

crazycapivara commented 4 years ago

Hi @su-park,

Before running devtools::install() you need to install the H3 C library.

The easiest way is to run the script included in the repo:

git clone https://github.com/crazycapivara/h3-r.git
pushd h3-r
chmod +x install-h3c.sh
# Install H3 C Library
./install-h3c.sh

# Install H3 for R
R -q -e 'devtools::install()'
popd
rm -rf h3-r
crazycapivara commented 4 years ago

See install-h3c.sh

su-park commented 4 years ago

Thank you for responding swiftly.

Actually, I have tried it but got the same message.

For some reason, installation code for H3 for R can't load h3 for C I guess.

`h3_hex-ring.cpp:2:10: fatal error: 'h3/h3api.h' file not found

include <h3/h3api.h>

     ^~~~~~~~~~~~

1 error generated. make: *** [h3_hex-ring.o] Error 1 ERROR: compilation failed for package ‘h3’

crazycapivara commented 4 years ago

Does install-h3c.sh run without errors? Can you for example run geoToH3 from the console afterwards?

Error points out that the h3 C library is not found.

crazycapivara commented 4 years ago

It looks in /usr/local/lib/ for the h3 C lib.

su-park commented 4 years ago

No.

It looks in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/ for the h3 C lib.

It worked for me.

I guess you need to check the assigned path for h3api.h.

Thanks anyway!

crazycapivara commented 4 years ago

That's fine. So, what did you do that it works for you.

In Makevars the path for additional libs is defined. This works on Linux systems I have tested so far and on the Travis OSX VM.

isaacbrodsky commented 4 years ago

This looks very similar to an issue I ran into when working on uber/h3#381, where h3/h3api.h isn't found after installing on OSX. I think there may have been a regression (probably in H3 3.6.4) where the installed H3 target doesn't set /usr/local/include as an include directory. I see this version of H3 isn't used in the install script here.

I wonder if what happened was that H3 version 3.6.4 (or master) was installed first, and then that installation was not usable.

JosiahParry commented 3 years ago

Just as a note: the easiest way I've found to install on OS X was with brew install h3