How to install R packages that use header files (RJSONIO, Rcpp)? - r

I'm unable to install several R packages because they always fail on the first include statement. This is the error I get for Rcpp:
install.packages("/Users/nacho/Downloads/Rcpp_0.10.3.tar.gz", repos=NULL, type="source")
Installing package(s) into ‘/Users/nacho/Library/R/2.15/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
c++ -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG -fopenmp -I/usr/local/include -fopenmp -fPIC -g -O2 -c Date.cpp -o Date.o
clang: warning: argument unused during compilation: '-fopenmp'
clang: warning: argument unused during compilation: '-fopenmp'
Date.cpp:29:10: fatal error: 'Rcpp/Datetime.h' file not found
#include <Rcpp/Datetime.h>
^
1 error generated.
make: *** [Date.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Users/nacho/Library/R/2.15/library/Rcpp’
Warning message:
In install.packages("/Users/nacho/Downloads/Rcpp_0.10.3.tar.gz", :
installation of package ‘/Users/nacho/Downloads/Rcpp_0.10.3.tar.gz’ had non-zero exit status
I get the same error for RJSONIO
install.packages("/Users/nacho/Downloads/RJSONIO_1.0-3.tar.gz", repos=NULL, type="source")
Installing package(s) into ‘/Users/nacho/Library/R/2.15/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘RJSONIO’ ...
** package ‘RJSONIO’ successfully unpacked and MD5 sums checked
Trying to find libjson.h header file
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
USE_LOCAL = ""
Minor Version: 6
Using local libjson code. Copying files from src/libjson/Source
/private/var/folders/tl/_8_djcq15pl01ht8z6hy9tww0000gn/T/RtmpMKCuPF/R.INSTALL116ed562675dc/RJSONIO
JSONAllocator.cpp
JSONChildren.cpp
JSONDebug.cpp
JSONIterators.cpp
JSONMemory.cpp
JSONNode.cpp
JSONNode_Mutex.cpp
JSONPreparse.cpp
JSONStream.cpp
JSONValidator.cpp
JSONWorker.cpp
JSONWriter.cpp
internalJSONNode.cpp
libjson.cpp
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating cleanup
** libs
cc -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG -fopenmp -I/usr/local/include -fopenmp -fPIC -g -O2 -c ConvertUTF.c -o ConvertUTF.o
clang: warning: argument unused during compilation: '-fopenmp'
clang: warning: argument unused during compilation: '-fopenmp'
c++ -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG -fopenmp -I/usr/local/include -fopenmp -fPIC -g -O2 -c JSONAllocator.cpp -o JSONAllocator.o
clang: warning: argument unused during compilation: '-fopenmp'
clang: warning: argument unused during compilation: '-fopenmp'
JSONAllocator.cpp:1:10: fatal error: 'JSONAllocator.h' file not found
#include "JSONAllocator.h"
^
1 error generated.
make: *** [JSONAllocator.o] Error 1
ERROR: compilation failed for package ‘RJSONIO’
* removing ‘/Users/nacho/Library/R/2.15/library/RJSONIO’
Warning message:
In install.packages("/Users/nacho/Downloads/RJSONIO_1.0-3.tar.gz", :
installation of package ‘/Users/nacho/Downloads/RJSONIO_1.0-3.tar.gz’ had non-zero exit status
My sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin11.4.2 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] graphics grDevices utils datasets stats grid methods base
other attached packages:
[1] clickme_0.0.3 ggplot2_0.9.3.1 testthat_0.7.1 devtools_1.1
loaded via a namespace (and not attached):
[1] colorspace_1.2-1 dichromat_2.0-0 digest_0.6.3 evaluate_0.4.3 formatR_0.7 gtable_0.1.2
[7] httr_0.2 knitr_1.1 labeling_0.1 MASS_7.3-23 memoise_0.1 munsell_0.4
[13] parallel_2.15.2 plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 RCurl_1.95-4.1 reshape2_1.2.2
[19] scales_0.2.3 stringr_0.6.2 tools_2.15.2 whisker_0.1 yaml_2.1.7

What happens when you try
R CMD INSTALL Rcpp_0.10.3.tar.gz
instead? From the log you show:
c++ -I/usr/local/Cellar/r/2.15.2/R.framework/Resources/include -DNDEBUG \
-fopenmp -I/usr/local/include -fopenmp -fPIC -g -O2 -c Date.cpp -o Date.o
it is clear that you are missing something. On my Linux box (and you can ignore the
fact that I use the current SVN version)
edd#max:~/svn/rcpp/pkg$ R CMD INSTALL Rcpp_0.10.3.1.tar.gz
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘Rcpp’ ...
** libs
ccache g++-4.7 -I/usr/share/R/include -DNDEBUG -I../inst/include/ \
-fpic -g0 -O3 -Wall -pipe -Wno-variadic-macros -pedantic -c Date.cpp -o Date.o
Notice the -I../inst/include here? Maybe you overwrote CXXFLAGS or something...

Related

Can't install nloptr package for R on CentOS 7

I am encountering the same type of problem as described in this question. However, in accordance with the answer, I have updated my R (version 4.1.3) and CMake (version 3.12.3) and I still can't seem to install the package. I am running CentOS 7.
Here is the log:
> install.packages("nloptr")
Installing package into ‘/home/userr/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/nloptr_2.0.0.tar.gz'
Content type 'application/x-gzip' length 2219414 bytes (2.1 MB)
==================================================
downloaded 2.1 MB
* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -std=gnu++11 accepts -g... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking if pkg-config knows NLopt... no
using NLopt via local cmake build on x86_64
set CMAKE_BIN=/usr/local/bin/cmake
set CC=gcc -std=gnu11
set CFLAGS=-I/usr/local/include -fpic -g -O2
set CXX=g++
set CXXFLAGS=-std=gnu++11 -I/usr/local/include -fpic -g -O2
set LDFLAGS=-L/usr/local/lib
CMake Error: The source directory "/tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt-build" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Error: /tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt-build is not a directory
CMake Error: The source directory "/tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
cp: cannot stat 'nlopt/include/*': No such file or directory
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c init_nloptr.c -o init_nloptr.o
gcc -std=gnu11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c nloptr.c -o nloptr.o
g++ -std=gnu++11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c test-C-API.cpp -o test-C-API.o
g++ -std=gnu++11 -I"/opt/R/4.1.3/lib/R/include" -DNDEBUG -I../inst/include -I'/home/userr/R/x86_64-pc-linux-gnu-library/4.1/testthat/include' -I/usr/local/include -fpic -g -O2 -c test-runner.cpp -o test-runner.o
g++ -std=gnu++11 -shared -L/opt/R/4.1.3/lib/R/lib -L/usr/local/lib -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -L/opt/R/4.1.3/lib/R/lib -lRlapack -L/opt/R/4.1.3/lib/R/lib -lRblas -lgfortran -lm -lquadmath -Lnlopt/lib -lnlopt -L/opt/R/4.1.3/lib/R/lib -lR
installing to /home/userr/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-nloptr/00new/nloptr/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package ‘nloptr’
finding HTML links ... done
auglag html
bobyqa html
ccsaq html
check.derivatives html
cobyla html
crs2lm html
direct html
is.nloptr html
isres html
lbfgs html
mlsl html
mma html
neldermead html
newuoa html
nl.grad html
nl.opts html
nloptr-package html
nloptr html
nloptr.get.default.options html
nloptr.print.options html
print.nloptr html
sbplx html
slsqp html
stogo html
tnewton html
varmetric html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/userr/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-nloptr/00new/nloptr/libs/nloptr.so':
libnlopt.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/userr/R/x86_64-pc-linux-gnu-library/4.1/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp3kX1wu/downloaded_packages’
I don't know what could be causing the error, but my guess is that this line from the above log is the most relevant:
CMake Error: The source directory "/tmp/RtmpVJjt9p/R.INSTALL27cf4036808b/nloptr/src/nlopt-build" does not exist.
I would be thankful for all the help as I don't know much about Linux systems.

To build an R package from source fails: Win10, RStudio

Installing a package from source fails for me on my windows machine. I uninstalled RStudio, R and deleted rtools40 folder, restarted and reinstalled those items. I believe I have the path set up appropriately.
Here's the code I tried, using some troubleshooting help from here:
#troubleshooting installation
pkgbuild::find_rtools()
pkgbuild::has_rtools(TRUE)
pkgbuild::check_rtools(TRUE)
pkgbuild::rtools_path()
pkgbuild::check_build_tools(TRUE)
pkgbuild::check_compiler(TRUE)
Sys.getenv("PATH")
Sys.getenv('BINPREF')
sessionInfo()
#Test installation from source via CRAN
pkgbuild::with_build_tools(install.packages("lme4", type = "source"))
And here is the output:
Restarting R session...
> #troubleshooting installation
> pkgbuild::find_rtools()
[1] TRUE
> pkgbuild::has_rtools(TRUE)
[1] TRUE
> pkgbuild::check_rtools(TRUE)
[1] TRUE
> pkgbuild::rtools_path()
[1] "C:\\rtools40/usr/bin"
> pkgbuild::check_build_tools(TRUE)
Your system is ready to build packages!
> pkgbuild::check_compiler(TRUE)
Trying to compile a simple C file
Running "C:/PROGRA~1/R/R-40~1.3/bin/x64/Rcmd.exe" SHLIB foo.c
Warning message:
In system(cmd) : 'make' not found
Error: Failed to compile C code
> Sys.getenv("PATH")
[1] "C:\\Program Files\\R\\R-4.0.3\\bin\\x64;C:\\rtools40\\bin;C:\\rtools40\\mingw64\\bin;C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\wbin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Pandoc\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Users\\nealm\\AppData\\Local\\Microsoft\\WindowsApps;C:\\ProgramData\\Anaconda3;C:\\ProgramData\\Anaconda3\\Scripts;C:\\Users\\nealm\\.conda\\pkgs\\conda-4.7.5-py37_0\\Scripts;C:\\ProgramData\\Anaconda3\\Library\\bin;C:\\Users\\nealm\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\nealm\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\nealm\\AppData\\Roaming\\TinyTeX\\bin\\win32;"
> Sys.getenv('BINPREF')
[1] "C:/rtools40/mingw64/bin/"
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 LC_MONETARY=English_New Zealand.1252
[4] LC_NUMERIC=C LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] processx_3.4.5 compiler_4.0.3 assertthat_0.2.1 R6_2.5.0 cli_2.2.0 livecode_0.1.0.9000
[7] prettyunits_1.1.1 tools_4.0.3 glue_1.4.2 rstudioapi_0.13 Rcpp_1.0.5 remotes_2.2.0
[13] crayon_1.3.4 fansi_0.4.1 callr_3.5.1 ps_1.4.0 pkgbuild_1.1.0
>
> #Test installation from source via CRAN
> pkgbuild::with_build_tools(install.packages("lme4", type = "source"))
Installing package into ‘C:/Rpackages’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/lme4_1.1-26.tar.gz'
Content type 'application/x-gzip' length 3297635 bytes (3.1 MB)
downloaded 3.1 MB
* installing *source* package 'lme4' ...
** package 'lme4' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c external.cpp -o external.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c glmFamily.cpp -o glmFamily.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c optimizer.cpp -o optimizer.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c predModule.cpp -o predModule.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.3/include" -DNDEBUG -I. -DNDEBUG -DEIGEN_DONT_VECTORIZE -I'C:/Rpackages/Rcpp/include' -I'C:/Rpackages/RcppEigen/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c respModule.cpp -o respModule.o
C:/rtools40/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o lme4.dll tmp.def external.o glmFamily.o optimizer.o predModule.o respModule.o -LC:/PROGRA~1/R/R-40~1.3/bin/i386 -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/R/R-40~1.3/bin/i386/R.dll when searching for -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/R/R-40~1.3/bin/i386/R.dll when searching for -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lR
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'lme4'
* removing 'C:/Rpackages/lme4'
* restoring previous 'C:/Rpackages/lme4'
Warning in install.packages :
installation of package ‘lme4’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\nealm\AppData\Local\Temp\RtmpwPwykm\downloaded_packages’
>
The problem does not appear to be specific to the lme4 package.
This is more of a work around than a proper answer. The alternative to installing and building from source is to install a pre-built binary. If one is not available, you can build it remotely.
In this case, for the package of interest for me, rundel/livecode on github, I:
Forked the repo (in this case rundel/livecode). This step might be optional.
Downloaded the tar.gz (remotes::install_github("markbneal/livecode") which doesn't install it, but the error tells you where it saves the .tar.gz file locally.
Used rhub to build the package binary for windows, go to this website https://builder.r-hub.io/ and upload your tar.gz file, ensuring rhub has your email address (click "advanced" button to provide your email address as alternate - you will need to validate it). That emails me a zip 5 minutes later.
Then copy the livecode folder in the zip that is emailed to me to my "R packages" folder location.
Package should now work for you, in my case library(livecode)
Edited six months later when I had to use this process again!

updating Rgdal in R.3.5.1 C++11 dependency... although C++11 is available

When I am updating (or at least trying to) the rgdal package by compiling from source after updating R from 3.4.4 to 3.5.1, I run into the odd issue that all goes well, but the namespace load fails due to an "undefined symbol" error:
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/rgdal/libs/rgdal.so':
/usr/local/lib/R/site-library/rgdal/libs/rgdal.so: undefined symbol: _ZNK10OGRFeature16GetFieldAsDoubleEi
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/rgdal’
* restoring previous ‘/usr/local/lib/R/site-library/rgdal’
The downloaded source packages are in
‘/tmp/RtmpHu6D0N/downloaded_packages’
Warning message:
In install.packages("rgdal") :
installation of package ‘rgdal’ had non-zero exit status
When running echo _ZNK10OGRFeature16GetFieldAsDoubleEi | c++filt I get as an output OGRFeature::GetFieldAsDouble(int) const which doesn't learn me much. I have installed GDAL from https://trac.osgeo.org/gdal/wiki/DownloadSource , as suggested on the CRAN package site which shows that I have GDAL 2.3.1 installed.
It is odd that updates fail, as the package was already installed, so dependencies should have been met. Any pointers as to how to resolve this issue are warmly welcome.
As I got no suggestions in the past few weeks I decided to uninstall rgdal, and reinstall it. Interestingly, now I get a claim that my system (Ubuntu 16.04.5 LTS) does not support C++11, although the check says it is there (C++11 support available):
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/lib/R
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
In file included from /usr/local/include/gdal.h:45:0,
from gdal_test.cc:1:
/usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or newer.
# error Must have C++11 or newer.
^
In file included from /usr/local/include/gdal.h:49:0,
from gdal_test.cc:1:
/usr/local/include/cpl_minixml.h:202:47: error: expected template-name before '<' token
class CPLXMLTreeCloser: public std::unique_ptr<CPLXMLNode, CPLXMLTreeCloserDeleter>
^
/usr/local/include/cpl_minixml.h:202:47: error: expected '{' before '<' token
/usr/local/include/cpl_minixml.h:202:47: error: expected unqualified-id before '<' token
In file included from /usr/local/include/ogr_api.h:45:0,
from /usr/local/include/gdal.h:50,
from gdal_test.cc:1:
/usr/local/include/ogr_core.h:79:28: error: expected '}' before end of line
/usr/local/include/ogr_core.h:79:28: error: expected declaration before end of line
In file included from /usr/local/include/gdal.h:45:0,
from gdal_test.cc:1:
/usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or newer.
# error Must have C++11 or newer.
^
In file included from /usr/local/include/gdal.h:49:0,
from gdal_test.cc:1:
/usr/local/include/cpl_minixml.h:202:47: error: expected template-name before '<' token
class CPLXMLTreeCloser: public std::unique_ptr<CPLXMLNode, CPLXMLTreeCloserDeleter>
^
/usr/local/include/cpl_minixml.h:202:47: error: expected '{' before '<' token
/usr/local/include/cpl_minixml.h:202:47: error: expected unqualified-id before '<' token
In file included from /usr/local/include/ogr_api.h:45:0,
from /usr/local/include/gdal.h:50,
from gdal_test.cc:1:
/usr/local/include/ogr_core.h:79:28: error: expected '}' before end of line
/usr/local/include/ogr_core.h:79:28: error: expected declaration before end of line
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/local/lib/R/site-library/rgdal’
My devtools::session_info() is the following:
Session info ------------------------------------------------------------------
setting value
version R version 3.5.1 (2018-07-02)
system x86_64, linux-gnu
ui X11
language en_US:en
collate en_US.UTF-8
tz Europe/Brussels
date 2018-07-28
Packages ----------------------------------------------------------------------
package * version date source
base * 3.5.1 2018-07-03 local
compiler 3.5.1 2018-07-03 local
datasets * 3.5.1 2018-07-03 local
devtools * 1.13.6 2018-06-27 CRAN (R 3.5.1)
digest 0.6.15 2018-01-28 CRAN (R 3.5.1)
graphics * 3.5.1 2018-07-03 local
grDevices * 3.5.1 2018-07-03 local
memoise 1.1.0 2017-04-21 CRAN (R 3.5.1)
methods * 3.5.1 2018-07-03 local
stats * 3.5.1 2018-07-03 local
tools 3.5.1 2018-07-03 local
utils * 3.5.1 2018-07-03 local
withr 2.1.2 2018-03-15 CRAN (R 3.5.1)
In my case, the solution was to update my ~/.R/Makevars config.
CC=clang
CXX=clang++
PKG_CFLAGS= -g -O2
I added: -std=gnu++11 to my CXX definition
CC=clang
CXX=clang++ -std=gnu++11
PKG_CFLAGS= -g -O2
after this, the compile problems and related error no longer occur (at least in my testing so far)
Inference
The above leads to the question - Why? A new install of R 3.5.1 with rgdal does not (in my experience) exhibit the compile error, whilst the upgrade from 3.4.4 does. My sense is that an interaction exists between R and rgdal package config that causes the C++11 compile flag to be not activated. rgdal requires and uses C++11 features. See Makevar - an overview below.
Citations:
R Installation and Administration
R Using Makevars
How do I enable C++11 in gcc?
Compile Example:
No -std=gnu++11 flag in Makevars [Errors]
> install.packages("rgdal")
--2018-08-10 21:31:58-- https://cran.rstudio.com/src/contrib/rgdal_1.3-4.tar.gz
Resolving cran.rstudio.com (cran.rstudio.com)... 52.84.17.191
Connecting to cran.rstudio.com (cran.rstudio.com)|52.84.17.191|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1664774 (1.6M) [application/x-gzip]
Saving to: ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’
/var/folders/md/03gdc4c14z18kbqwpfh4jd 100%[============================================================================>] 1.59M --.-KB/s in 0.04s
2018-08-10 21:31:58 (35.6 MB/s) - ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’ saved [1664774/1664774]
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /Users/***/.Renv/versions/3.5.1/lib/R
configure: CC: clang
configure: CXX: clang++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/opt/gdal2/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal2/2.3.1/include/gdal.h:45:
/usr/local/Cellar/gdal2/2.3.1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
In file included from gdal_test.cc:1:
In file included from /usr/local/Cellar/gdal2/2.3.1/include/gdal.h:45:
/usr/local/Cellar/gdal2/2.3.1/include/cpl_port.h:187:6: error: Must have C++11 or newer.
# error Must have C++11 or newer.
^
1 error generated.
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Users/***/.Renv/versions/3.5.1/lib/R/library/rgdal’
The downloaded source packages are in
‘/private/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T/RtmpidZNr4/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rgdal") :
installation of package ‘rgdal’ had non-zero exit status
Added -std=gnu++11 to Makevars
> install.packages("rgdal")
--2018-08-10 21:34:20-- https://cran.rstudio.com/src/contrib/rgdal_1.3-4.tar.gz
Resolving cran.rstudio.com (cran.rstudio.com)... 52.84.17.191
Connecting to cran.rstudio.com (cran.rstudio.com)|52.84.17.191|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1664774 (1.6M) [application/x-gzip]
Saving to: ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’
/var/folders/md/03gdc4c14z18kbqwpfh4jd 100%[============================================================================>] 1.59M --.-KB/s in 0.04s
2018-08-10 21:34:20 (43.5 MB/s) - ‘/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T//RtmpidZNr4/downloaded_packages/rgdal_1.3-4.tar.gz’ saved [1664774/1664774]
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /Users/***/.Renv/versions/3.5.1/lib/R
configure: CC: clang
configure: CXX: clang++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/opt/gdal2/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/local/Cellar/gdal2/2.3.1/share/gdal/pcs.csv readable... yes
configure: pkg-config proj exists, will use it
configure: PROJ version: 5.1.0
checking proj_api.h presence and usability... yes
checking PROJ version >= 4.8.0... yes
checking projects.h presence and usability... yes
checking PROJ.4: epsg found and readable... yes
checking PROJ.4: conus found and readable... yes
configure: Package CPP flags: -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include
configure: Package LIBS: -L/usr/local/Cellar/gdal2/2.3.1/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c OGR_write.cpp -o OGR_write.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c gdal-bindings.cpp -o gdal-bindings.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c init.c -o init.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c inverser.c -o inverser.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c local_stubs.c -o local_stubs.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogr_geom.cpp -o ogr_geom.o
clang -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -fPIC -g -O2 -c ogr_polygons.c -o ogr_polygons.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogr_proj.cpp -o ogr_proj.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogrdrivers.cpp -o ogrdrivers.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c ogrsource.cpp -o ogrsource.o
g++ -std=gnu++11 -I"/Users/***/.Renv/versions/3.5.1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal2/2.3.1/include -I/usr/local/Cellar/proj/5.1.0/include -I"/Users/***/.Renv/versions/3.5.1/lib/R/library/sp/include" -I/usr/local/opt/gdal2/include -I/usr/local/opt/liblas-gdal2/include -I/usr/local/opt/laszip#2.2/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -g -O2 -stdlib=libc++ -std=c++11 -fPIC -g -O2 -c projectit.cpp -o projectit.o
g++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/***/.Renv/versions/3.5.1/lib/R/lib -L/usr/local/opt/gdal2/lib -L/usr/local/opt/liblas-gdal2/lib -L/usr/local/opt/laszip#2.2/lib -L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib -o rgdal.so OGR_write.o gdal-bindings.o init.o inverser.o local_stubs.o ogr_geom.o ogr_polygons.o ogr_proj.o ogrdrivers.o ogrsource.o projectit.o -L/usr/local/Cellar/gdal2/2.3.1/lib -lgdal -lproj -L/Users/***/.Renv/versions/3.5.1/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/***/.Renv/versions/3.5.1/lib/R/library/rgdal/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (rgdal)
The downloaded source packages are in
‘/private/var/folders/md/03gdc4c14z18kbqwpfh4jdfc0000gr/T/RtmpidZNr4/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
MakeVars - An Overview:
Makevars is a makefile that overrides the default makefile generated by R (which is located at file.path(R.home("etc"), "Makeconf")). This allows you to take advantage of R’s default behaviour while being able to set the flags you need. These are the most commonly used flags:
PKG_LIBS
Linker flags. A common use is PKG_LIBS = $(BLAS_LIBS). This allows you to use the same BLAS library as R.
PKG_CFLAGS and PKG_CXXFLAGS
C and C++ flags. Most commonly used to set define directives with -D.
PKG_CPPFLAGS
Preprocessor flags (not C++ flags!). Most commonly used to set include directories with -I. Any package listed in the LinkingTo field in the DESCRIPTION will be automatically included—you do not need to explicitly add it.
I hope the above helps point you in the direction of a solution.
What worked for me is the following sequence (Ubuntu 16.04.5 LTS):
sudo add-apt-repository -y ppa:ubuntugis/ppa
sudo apt update
# I didn't have gdal previously, so I cannot just upgrade below.
# Also note that I'm using the python library as well, which you may not want.
sudo apt install gdal-bin python-gdal python3-gdal
# the above also covered **PROJ.4**, therefore below was not needed
# sudo apt install proj-bin
sudo apt install libgdal1-dev
sudo apt install libgdal1i
# gdalinfo --version
> GDAL 2.1.3, released 2017/20/01
Afterwards, I could simply run install.packages("rgdal") under R 3.5.1.
Related references here:
python GDAL 2.1 installation on Ubuntu 16.04
Error: gdal-config not found

R: Installing purrr from local returns error (fatal error: dplyr.h: No such file or directory)

UPDATE - Problem solved:
It seems like the way I set up .libPaths() (see comments below) loaded dplyr from a network directory, which somehow blocked the installation process of purrr. As soon as I installed and loaded dplyr from my local library I could install purrr.
I tried installing purrr from a local version of the package (purrr_0.2.2.tar.gz; see CRAN website). My installation attempt returns an error (fatal error: dplyr.h: No such file or directory):
> install.packages("H:/R_packages/purrr_0.2.2.tar.gz", # directory of the downloaded file
+ repos = NULL,
+ type = c("source"),
+ INSTALL_opts = "--no-test-load",
+ lib = "H:/R_packages") # where to install the package
'\\userhome\ABCD1234'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
* installing *source* package 'purrr' ...
** package 'purrr' successfully unpacked and MD5 sums checked
** libs
gcc -m64 -I"C:/R/R-3.2.1/include" -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I"H:/R_packages/Rcpp/include" -I"\\mypath//R/Lib/CRAN/3.2/dplyr/include" -I"H:/R_packages/BH/include" -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall -std=gnu99 -mtune=core2 -c extract.c -o extract.o
g++ -m64 -I"C:/R/R-3.2.1/include" -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I"H:/R_packages/Rcpp/include" -I"\\mypath/R/Lib/CRAN/3.2/dplyr/include" -I"H:/R_packages/BH/include" -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall -mtune=core2 -c fast-copy.cpp -o fast-copy.o
gcc -m64 -I"C:/R/R-3.2.1/include" -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I"H:/R_packages/Rcpp/include" -I"\\mypath/R/Lib/CRAN/3.2/dplyr/include" -I"H:/R_packages/BH/include" -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall -std=gnu99 -mtune=core2 -c flatten.c -o flatten.o
gcc -m64 -I"C:/R/R-3.2.1/include" -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I"H:/R_packages/Rcpp/include" -I"\\mypath/R/Lib/CRAN/3.2/dplyr/include" -I"H:/R_packages/BH/include" -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall -std=gnu99 -mtune=core2 -c map.c -o map.o
g++ -m64 -I"C:/R/R-3.2.1/include" -DNDEBUG -I../inst/include -DCOMPILING_DPLYR -I"H:/R_packages/Rcpp/include" -I"\\mypath/R/Lib/CRAN/3.2/dplyr/include" -I"H:/R_packages/BH/include" -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall -mtune=core2 -c rows-data.cpp -o rows-data.o
rows-data.cpp:2:19: fatal error: dplyr.h: No such file or directory
compilation terminated.
make: *** [rows-data.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-3.2.1/etc/x64/Makeconf" -f "C:/R/R-3.2.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="purrr.dll" WIN=64 TCLBIN=64 OBJECTS="extract.o fast-copy.o flatten.o map.o rows-data.o rows-formatter.o rows.o transpose.o utils.o vector.o"' had status 2
ERROR: compilation failed for package 'purrr'
* removing 'H:/R_packages/purrr'
Warning in install.packages :
running command '"C:/R/R-3.2.1/bin/x64/R" CMD INSTALL --no-test-load -l "H:\R_packages" "H:/R_packages/purrr_0.2.2.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘H:/R_packages/purrr_0.2.2.tar.gz’ had non-zero exit Status
I used the same approach for a lot of other packages (broom, modelr, forcats etc.), and it always worked. Does anybody have an idea why the package installation fails in this particular case?
> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252 LC_MONETARY=German_Switzerland.1252
[4] LC_NUMERIC=C LC_TIME=German_Switzerland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.4.2
loaded via a namespace (and not attached):
[1] magrittr_1.5 R6_2.1.0 assertthat_0.1 parallel_3.2.1 DBI_0.3.1 tools_3.2.1 Rcpp_0.12.0

Cannot Install "tm" package in R macOS Sierra

When calling install.packages("tm") I get the following error:
> install.packages("tm")
Installing package into ‘/usr/local/lib/R/3.3/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://ftp.cixug.es/CRAN/src/contrib/tm_0.7.tar.gz'
Content type 'application/x-gzip' length 526498 bytes (514 KB)
==================================================
downloaded 514 KB
* installing *source* package ‘tm’ ...
** package ‘tm’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/usr/local/Cellar/r/3.3.2/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/BH/include" -I"/usr/local/lib/R/3.3/site-library/Rcpp/include" -fPIC -g -O2 -c RcppExports.cpp -o RcppExports.o
clang -I/usr/local/Cellar/r/3.3.2/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/BH/include" -I"/usr/local/lib/R/3.3/site-library/Rcpp/include" -fPIC -g -O2 -c copy.c -o copy.o
clang -I/usr/local/Cellar/r/3.3.2/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/BH/include" -I"/usr/local/lib/R/3.3/site-library/Rcpp/include" -fPIC -g -O2 -c init.c -o init.o
clang++ -I/usr/local/Cellar/r/3.3.2/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/BH/include" -I"/usr/local/lib/R/3.3/site-library/Rcpp/include" -fPIC -g -O2 -c tdm.cpp -o tdm.o
In file included from tdm.cpp:4:
/usr/local/lib/R/3.3/site-library/BH/include/boost/tokenizer.hpp:59:9: error: field of type 'std::__1::__wrap_iter<const char *>' has private constructor
: first_(c.begin()), last_(c.end()), f_() { }
^
tdm.cpp:25:28: note: in instantiation of function template specialization 'boost::tokenizer<boost::char_delimiters_separator<char, std::__1::char_traits<char> >, std::__1::__wrap_iter<const char *>, std::__1::basic_string<char> >::tokenizer<Rcpp::internal::const_string_proxy<16> >' requested here
boost::tokenizer<> tok(strings(index));
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:1239:31: note: declared private here
_LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
^
In file included from tdm.cpp:4:
/usr/local/lib/R/3.3/site-library/BH/include/boost/tokenizer.hpp:59:28: error: field of type 'std::__1::__wrap_iter<const char *>' has private constructor
: first_(c.begin()), last_(c.end()), f_() { }
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:1239:31: note: declared private here
_LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
^
2 errors generated.
make: *** [tdm.o] Error 1
ERROR: compilation failed for package ‘tm’
* removing ‘/usr/local/lib/R/3.3/site-library/tm’
Warning in install.packages :
installation of package ‘tm’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/02/6mkk426d3jd46mg35j577bwc0000gn/T/RtmpHPgAoU/downloaded_packages’
My computer runs macOS Sierra. The output of sessionInfo() is:
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin16.3.0 (64-bit)
Running under: macOS Sierra 10.12.3
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.3.2
I didn't have problems installing "slam" as other posts mentioned. I have also tried installing "tm" with the dependencies flag set to TRUE but yields the same output. I installed R via homebrew. I wonder if there are any other steps I can try.
I've been having the same issue. For now, I've installed tm 0.6 from the cran.r-project website. This eliminated the compilation errors for me.

Resources