I am trying to compile sf from CRAN on our local linux cluster, but I can't get it to work.
We have GDAL 2.3.0 and R (3.5.1) is compiled with intel's ICPC (2017).
ThIs is the output of install.packages(sf).
The first error seems to be this:
/opt-ictp/R/gdal-2.3.0/include/cpl_port.h(187): error: #error directive: Must have C++11 or newer.
Thus I have tried to compile with:
install.packages("sf", configure.args="CFLAGS='-std=c++11'")install.packages("sf", configure.args="CXXFLAGS='-std=c++11'")install.packages("sf", configure.vars="CFLAGS='-std=c++11'")install.packages("sf", configure.vars="CXXFLAGS='-std=c++11'")install.packages("sf", configure.args="CXX1XSTD='-std=c++11'")install.packages("sf", configure.vars="CXX1XSTD='-std=c++11'")install.packages("sf", configure.args="CXX1XSTD='c++11'")install.packages("sf", configure.vars="CXX1XSTD='c++11'")The error persists.
As you can see this was pretty much trial and error - I really don't know anything about this.
This is the output of cat $(R RHOME)/etc/Makeconf.
Any idea on how to fix this?
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS: /opt-ictp/R/3.5.1/lib64/R/lib/libRblas.so
LAPACK: /opt-ictp/R/3.5.1/lib64/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1
Since gdal 2.3.0 got installed, which required c++11, somebody must have figured out how to configure the compiler to get this done. Find that person, and use the compiler flags used for that.
Might be related to the problems reported in #726.
I had the same issue on my CentOS machine, I had to install GDAL 2.2 which does not require C++11...
The tech support of my cluster told me they managed to install sf from CRAN with GDAL 2.3.0. Unfortunately I do not know how. Closing this, thanks.
I am working on macOS High Sierra version 10.13.6 . I installed gdal 2.3.1 via homebrew following this post.
$> gdal-config --version
2.3.1
While installing sf, I encountered the above-mentioned error.
/opt-ictp/R/gdal-2.3.0/include/cpl_port.h(187): error: #error directive: Must have C++11 or newer.
After diggling on the web, I found this useful topic. Then I configured the CXX with clang++ -std=gnu++11 in ~/.R/Makevars.
CC=clang
CXX=clang++ -std=gnu++11
PKG_CXXFLAGS= -stdlib=libc++ -std=c++11
Finally I successfully installed sf and rgdal packages from CRAN by
install.packages("sf")
install.packages("rgdal")
Most helpful comment
I am working on macOS High Sierra version 10.13.6 . I installed gdal 2.3.1 via homebrew following this post.
While installing
sf, I encountered the above-mentioned error.After diggling on the web, I found this useful topic. Then I configured the
CXXwithclang++ -std=gnu++11in~/.R/Makevars.Finally I successfully installed
sfandrgdalpackages from CRAN by