crazycapivara / h3-r

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

Unable to install on WSL #32

Closed singhkpratham closed 4 years ago

singhkpratham commented 4 years ago

Followed instructions to build h3, and it works till ./install-h3c.sh

But then R -q -e 'devtools::install()' gives following error. The same error is thrown if I directly try devtools::install_github("crazycapivara/h3-r") from within R.

Running /usr/lib/R/bin/R CMD INSTALL /tmp/Rtmpgg2BAk/h3_3.3.2.tar.gz \
  --install-tests
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘h3’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c h3_hex-ring.cpp -o h3_hex-ring.o
h3_hex-ring.cpp:2:10: fatal error: h3/h3api.h: No such file or directory
 #include <h3/h3api.h>
          ^~~~~~~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:177: recipe for target 'h3_hex-ring.o' failed
make: *** [h3_hex-ring.o] Error 1
ERROR: compilation failed for package ‘h3’
* removing ‘/usr/local/lib/R/site-library/h3’

Error: System command 'R' failed, exit status: 1, stdout & stderr were printed
singhkpratham commented 4 years ago

I followed h3 installation steps from uber/h3 page. Finished succesfully, but now I am getting this

error:

/usr/bin/ld: /usr/local/lib/libh3.a(algos.c.o): relocation R_X86_64_PC32 against symbol `baseCellNeighbors' can not be used when making a shared object; recompile with -fPIC
crazycapivara commented 4 years ago

@singhkpratham It is important that you build it as shared lib as declared in the error message. For example you can do this:

cmake -DENABLE_FORMAT=OFF -DBUILD_SHARED_LIBS=ON .

or build it with the -fPIC flag

crazycapivara commented 4 years ago

./install-h3c.sh does compile and install h3 without errors?

R then searches for the lib in /usr/local/lib

singhkpratham commented 4 years ago

Thanks a lot @crazycapivara . The cmake command worked, and then devtools::install_github("crazycapivara/h3-r") also worked.

And no, I checked later to find that ./install-h3c.sh also didn't complete without error.

@singhkpratham It is important that you build it as shared lib as declared in the error message. For example you can do this:

cmake -DENABLE_FORMAT=OFF -DBUILD_SHARED_LIBS=ON .

or build it with the -fPIC flag