OpenMP support in R and RcppArmadillo - r

I struggle to enable OpenMP support for R in Ubuntu 16.04. When installing RcppArmadillo, OpenMP is 'found', but I get the following message when installing packages (e.g. 'forecast') that depend on RcppArmadillo:
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-
library/Rcpp/include" -I"/usr/local/lib/R/site-
library/RcppArmadillo/include" -fpic -g -O2 -fstack-protector-strong -
Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
calcBATS.cpp -o calcBATS.o
In file included from /usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo:53:0,
from /usr/local/lib/R/site-
library/RcppArmadillo/include/RcppArmadilloForward.h:46,
from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:31,
from calcBATS.h:36,
from calcBATS.cpp:1:
/usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo_bits/compiler_setup.hpp:474:96:
note: #pragma message: WARNING: use of OpenMP disabled; this compiler
doesn't support OpenMP 3.0+
#pragma message ("WARNING: use of OpenMP disabled; this compiler doesn't
support OpenMP 3.0+")
My ~/.R/Makevars are the following:
VER=-5.4
CC=ccache gcc-$(VER)
CXX=ccache g++-$(VER)
FC=ccache gfortran
F77=ccache gfortran
CXX11 =ccache g++-$(VER)
CXX14=ccache g++-$(VER)
CXX_STD = CXX11
CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
FCFLAGS=-O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
CXXFLAGS = -O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
CXX11FLAGS = -O3 -Wall -pipe -pedantic -std=gnu11 -fopenmp
CXX14FLAGS = -O3 -Wall -pipe -pedantic -std=gnu14 -fopenmp
PKG_CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp
PKG_CXXFLAGS= -fopenmp
PKG_LIBS = -fopenmp -lgomp
CFLAGS= -O3 -Wall -pipe -pedantic -std=gnu99 -fopenmp
FCFLAGS=-O3 -g0 -Wall -pipe -fopenmp
I have played around with these settings, but nothing seems to help. Any wise thoughts would be appreciated. Many thanks.
Update:
I think some packages are using openMP now (e.g. xgboost). However, I still get the error message with some packages (e.g. Amelia):
* installing *source* package ‘Amelia’ ...
** package ‘Amelia’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-
library/Rcpp/include" -I"/usr/local/lib/R/site-
library/RcppArmadillo/include" -fpic -g -O2 -fstack-protector-strong -
Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
em.cpp -o em.o
In file included from /usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo:53:0,
from /usr/local/lib/R/site-
library/RcppArmadillo/include/RcppArmadilloForward.h:46,
from /usr/local/lib/R/site-
library/RcppArmadillo/include/RcppArmadillo.h:31,
from em.h:3,
from em.cpp:2:
/usr/local/lib/R/site-
library/RcppArmadillo/include/armadillo_bits/compiler_setup.hpp:474:96:
note: #pragma message: WARNING: use of OpenMP disabled; this compiler
doesn't support OpenMP 3.0+
#pragma message ("WARNING: use of OpenMP disabled; this compiler doesn't
support OpenMP 3.0+")
^
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o
Amelia.so em.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -
lR
installing to /usr/local/lib/R/site-library/Amelia/libs
I can see that Amelia does not finish with '-fopenmp' unlike xgboost, but I don't know what else to add to my ~/.R/Makevars. Installation of xgboost ends in the following (note the -fopenmp):
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-
z,relro -o xgboost.so ./xgboost_R.o ./xgboost_custom.o ./xgboost_assert.o
./amalgamation/xgboost-all0.o ./amalgamation/dmlc-minimum0.o
./rabit/src/engine_empty.o ./rabit/src/c_api.o -fopenmp -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/xgboost/libs

The comment by #hejseb is correct. (Rcpp)Armadillo now wants to use OpenMP when it can---on new enough compilers.
But client packages need to turn this on, meaning they have to change their file src/Makevars from having just
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
to
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
to enable OpenMP in the client package on both compilation and linking.
And e.g. the forecast package does not yet do that.
You can also set "global" #define in your ~/.R/Makevars to skip OpenMP if you find this too noisy. But you'd leave some performance on the table, which is not a good default. Which is why (Rcpp)Armadillo makes the noisy comment.
Edit: There is one minor nuisance in that you need to set the flags for every C++ dialect so make sure you set CFLAGS, CXXFLAGS, CXX11FLAGS and CXX14FLAGS. You should see the -fopenmp on the command-line when R CMD INSTALL ... does its work.

Related

Brew clang++ issue with cmath in OSX Catalina

Having a recurring issue with cmath upon compiling the source R package in OSX 10.15, as follows;
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/complex:245:
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:313:9: error: no member named 'signbit' in the global namespace
using ::signbit;
~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:314:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:315:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
~~^
/usr/local/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
Installation output from R shows clang++ with following arguments;
clang++ -fopenmp -std=gnu++11 -I"/usr/local/Cellar/r/3.6.2/lib/R/include" -DNDEBUG -I"/Volumes/Documents/Library/R/3.x/library/BH/include" -I"/Volumes/Documents/Library/R/3.x/library/Rcpp/include" -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include -fPIC -g -O3 -Wall -pipe -Wno-nonnull -pedantic -std=c++11 -mtune=native -c AlphaProcedure.cpp -o AlphaProcedure.o
I've read several similar posting having the similar issues but none of workaround has worked on my system so far. I'd really appreciate any input on this.
My system:
sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.2
BuildVersion: 19C57
xcodebuild -version
Xcode 11.3
Build version 11C29
clang -v
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.2.0_3/libexec/gcc/x86_64-apple-darwin19/9.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../configure --build=x86_64-apple-darwin19 --prefix=/usr/local/Cellar/gcc/9.2.0_3 --libdir=/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.2.0_3' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
Thread model: posix
gcc version 9.2.0 (Homebrew GCC 9.2.0_3)
C complier flags in zshrc
CPATH=/usr/local/include
CPPFLAGS=-I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
LDFLAGS=-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib
Makevars (for R)
LLVM_LOC = /usr/local/opt/llvm
CC=clang -fopenmp
CXX=clang++ -foropenmp
CXX11=clang++ -fopenmp
CFLAGS = -g -O3 -Wall -pipe -pedantic -Wno-nonnull -std=gnu99 -mtune=native -pipe
CXXFLAGS = -g -O3 -Wall -pipe -Wno-nonnull -pedantic -std=c++11 -mtune=native
CXX11FLAGS = -g -O3 -Wall -pipe -Wno-nonnull -pedantic -std=c++11 -mtune=native
LDFLAGS=-L/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include
I took the nuclear option (clean install Catalina) and used llvm provided by Apple with Brew installation of some required apps. All of this fixed the issue. One minor fix is in Makevars with CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

RcppArmadillo: failing to install on Ubuntu16.04

I am trying to install Rcpp on Ubuntu. Here are some environment details:
R version:3.4.0
g++ --version: Ubuntu 5.4.0-6ubuntu1~16.04.4
If I have a blank Makevars file, RcppArmadillo can be installed but with some warnings about OpenMp
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from RcppArmadillo.cpp:22:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from RcppExports.cpp:4:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c fastLm.cpp -o fastLm.o
In file included from ../inst/include/armadillo:52:0,
from ../inst/include/RcppArmadilloForward.h:46,
from ../inst/include/RcppArmadillo.h:31,
from fastLm.cpp:22:
../inst/include/armadillo_bits/compiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags")
^
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
After I added PKG_CXXFLAGS=-std=c++11 to Makevars, I got a error message as following:
g++ -I/usr/share/R/include -DNDEBUG -I"/home/march/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -std=c++11 -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppArmadillo.cpp -o RcppArmadillo.o
RcppArmadillo.cpp:22:27: fatal error: RcppArmadillo.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:168: recipe for target 'RcppArmadillo.o' failed
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo’
* restoring previous ‘/home/march/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo’
Warning in install.packages :
installation of package ‘RcppArmadillo’ had non-zero exit status
The wield thing is that when I tried to re-install RcppArmadillo on my mac(10.11), the same problem occurred. Could anybody enlighten me?
This is 16.10 which I have here at hone, if you wish I can repeat it at work tomorrow with 16.04:
edd#bud:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
edd#bud:~$ Rscript -e 'install.packages("RcppArmadillo")'
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RcppArmadillo_0.7.960.1.1.tar.gz'
Content type 'application/x-gzip' length 1115539 bytes (1.1 MB)
==================================================
downloaded 1.1 MB
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
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 ccache g++ accepts -g... yes
checking how to run the C++ preprocessor... ccache g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether ccache g++ accepts -g... (cached) yes
checking whether g++ version is sufficient... (6.2.0) yes
checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... found
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloLapack.h
** libs
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c RcppArmadillo.cpp -o RcppArmadillo.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c RcppExports.cpp -o RcppExports.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fopenmp -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c fastLm.cpp -o fastLm.o
ccache g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/RcppArmadillo/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RcppArmadillo)
The downloaded source packages are in
‘/tmp/Rtmp2hQNrn/downloaded_packages’
edd#bud:~$
That I usee ccache is not material. This. Just. Works.

What does `LinkingTo` do in an R package? [duplicate]

This question already has an answer here:
Do I need to import RccpEigen in the DESCRIPTION file for an R package using it, or is "LinkingTo" enough?
(1 answer)
Closed 5 years ago.
I am building an R package whose description contains:
LinkingTo: Rcpp
The package has a fairly deep makefile structure. I know using R CMD build . creates and modifies variables such as CXX11FLAGS which must be passed down through subsequent layers of makefiles.
I suspect that LinkingTo also produces such a variable, which I must be aware of and pass along. I suspect this because, several layers down, I hit the error:
mycode.hpp:5:10: fatal error: Rcpp.h: No such file or directory
#include <Rcpp.h>
I'm not sure how to inform this file's makefile as to where Rcpp is. I suspect the hypothesized variable could be used, but I do not know that variable's name. Can anyone clarify?
Here is LinkingTo: from a smaller in-progress package of mine:
LinkingTo: Rcpp, RcppArmadillo
When compiling, these two packages are both uses via -I... switches:
edd#bud:~/git/rcppkalman(master)$ ./cleanup
edd#bud:~/git/rcppkalman(master)$ R CMD INSTALL .
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘RcppKalman’ ...
** libs
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c RcppExports.cpp -o RcppExports.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c expmMat.cpp -o expmMat.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c kfpredict.cpp -o kfpredict.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c kfupdate.cpp -o kfupdate.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c ltidisc.cpp -o ltidisc.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c rtssmooth.cpp -o rtssmooth.o
ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -Werror -march=native -c tfsmooth.cpp -o tfsmooth.o
g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o RcppKalman.so RcppExports.o expmMat.o kfpredict.o kfupdate.o ltidisc.o rtssmooth.o tfsmooth.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/RcppKalman/libs
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (RcppKalman)
edd#bud:~/git/rcppkalman(master)$
There is nothing else needed. Writing R Extensions says:
A package that wishes to make use of header files in other packages
needs to declare them as a comma-separated list in the field
'LinkingTo' in the 'DESCRIPTION' file. For example
LinkingTo: link1, link2
The 'LinkingTo' field can have a version requirement which is checked
at installation.
Specifying a package in 'LinkingTo' suffices if these are C++
headers containing source code or static linking is done at
installation: the packages do not need to be (and usually should not
be) listed in the 'Depends' or 'Imports' fields. This includes CRAN
package BH (https://CRAN.R-project.org/package=BH) and almost all
users of
RcppArmadillo (https://CRAN.R-project.org/package=RcppArmadillo) and
RcppEigen (https://CRAN.R-project.org/package=RcppEigen).
For another use of 'LinkingTo' see *note Linking to native routines
in other packages::.
and that is on point as can be seen from the (essentially empty) src/Makevars:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
which is the standard uses by RcppArmadillo to support the external linking for LAPACK and BLAS. Note that my package is a little behind as RcppArmadillo in its most recent release now uses this inst/skeleton/Makevars passes into every package created via RcppArmadillo.package.skeleton():
## optional
#CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
to also support OpenMP where available. That is the current recommended form.
I edited my Makefile to include the following dark magic:
VARS_OLD := $(.VARIABLES)
$(foreach v, \
$(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)), \
$(info $(v) = $($(v))))
This prints out all of the environmental variables passed to the make process by R when you run R CMD build ..
Digging in this revealed some very interesting variables:
ALL_CPPFLAGS = -I/usr/share/R/include -DNDEBUG -I"/home/myuser/.R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"
CLINK_CPPFLAGS = -I"/home/myuser/.R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"
R_INCLUDE_DIR = /usr/share/R/include
Note that these variables contain the -I flag and, thus, must be communicated to any part of the build process that relies on those.
By passing these between makefiles I was able to achieve compilation.

Installation of rgdal fails in Gentoo with inverser.c include directive

I am trying to install rgdal (a dependency of gstat) in R on a Calculate Linux (effectively a generic Gentoo) clean installation. I have sci-libs/gdal installed. Here are the last few lines of output:
x86_64-pc-linux-gnu-g++ -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c OGR_write.cpp -o OGR_write.o
x86_64-pc-linux-gnu-g++ -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c gdal-bindings.cpp -o gdal-bindings.o
x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c init.c -o init.o
x86_64-pc-linux-gnu-gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/include/gdal -I"/home/wjc721/R/x86_64-pc-linux-gnu-library/3.2/sp/include" -fpic -O2 -march=x86-64 -pipe -c inverser.c -o inverser.o
inverser.c:3:22: fatal error: projects.h: No such file or directory
#include <projects.h>
^
compilation terminated.
Existing answers on Stackoverflow are for Linux distributions other than Gentoo. They suggest installation of packages (in Debian) such as libgdal1h, libgdal1-dev, libproj-dev and gdal-bin, none of which exist in Gentoo.
Any help would be very much appreciated! It was working fine on the previous version of Calculate :(
Thanks,
Bill
Edit: I upgraded R from v3.2.2 to 3.3.2 and gdal from 2.0.2-r3 to 2.0.3. This did not help, the error is the same.
I encountered the same problem. Upgrading to proj-4.9.2 did the trick.

R install package Rcplex

I already follow INSTALL STEP at INSTALL
but something wrong happen when I install the package
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex.c -o Rcplex.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_QCP.c -o Rcplex_QCP.o
Rcplex_QCP.c: In function 'Rcplex_QCP':
Rcplex_QCP.c:37:7: warning: unused variable 'trace' [-Wunused-variable]
int trace = INTEGER(getListElement(control,"trace"))[0];
^
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_params.c -o Rcplex_params.o
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG -I"C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rcplex_utils.c -o Rcplex_utils.o
C:/Rtools/mingw_32/bin/../lib/gcc/i686-w64-mingw32/4.9.3/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lcplex1263
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'Rcplex'
When you go to the package documentation at: https://cran.r-project.org/web/packages/Rcplex/index.html ... You make no mention of satisfying the system requirements:
SystemRequirements: IBM ILOG CPLEX libraries and headers
The linker that gcc uses, ld, cannot find the shared library for CPLEX. According to the INSTALL document, you need to verify that CPLEX_LIB_PATH is defined to point to the path where the CPLEX dll's are located. From your output, I'd venture
set CPLEX_LIB_PATH="C:/Program Files/IBM/ILOG/CPLEX_Studio_Community1263/cplex/lib"
is what you need.

Resources