Repository navigation
Arma version selection: Package without deprecation notes ready for C++14 or later #476
Copy link
Copy link
Closed
Description
As an example of a simple package that
- neither depends on or enforces C++11 but simply uses the newest C++ standard available
- does not trigger any deprecation warnings
we show the (not yet on CRAN but recent) example package rcppmlpackexamples of using mlpack via its C++ API directly from an R package. It also works the exact same way in CRAN packages RcppDE as well as for several local packages of mine not on CRAN such as RcppKalman or winsorize (details not shown here).
Example of default compilation before any changes: falls back to 14.6.3 with warning
Details
edd@paul:~/git/rcppmlpack-examples(master)$ install.r
* installing *source* package found in current working directory ...
* installing *source* package ‘rcppmlpackexamples’ ...
** this is package ‘rcppmlpackexamples’ version ‘0.0.1’
** using staged installation
** libs
using C++ compiler: ‘g++ (Ubuntu 14.2.0-19ubuntu2) 14.2.0’
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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c kMeans.cpp -o kMeans.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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c linearRegression.cpp -o linearRegression.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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c loadDefaultPrediction.cpp -o loadDefaultPrediction.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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c randomForest.cpp -o randomForest.o
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
from RcppExports.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/version/arma.h:71:153: note: ‘#pragma message: Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.’
71 | #pragma message("Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.")
| ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
from rcppmlpackexamples.h:18,
from kMeans.cpp:2:
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/version/arma.h:71:153: note: ‘#pragma message: Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.’
71 | #pragma message("Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.")
| ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
from rcppmlpackexamples.h:18,
from linearRegression.cpp:2:
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/version/arma.h:71:153: note: ‘#pragma message: Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.’
71 | #pragma message("Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.")
| ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
from rcppmlpackexamples.h:18,
from randomForest.cpp:2:
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/version/arma.h:71:153: note: ‘#pragma message: Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.’
71 | #pragma message("Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.")
| ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
from rcppmlpackexamples.h:18,
from loadDefaultPrediction.cpp:2:
/usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/version/arma.h:71:153: note: ‘#pragma message: Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.’
71 | #pragma message("Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT. See GitHub issue #475 for more.")
| ^
ccache g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -o rcppmlpackexamples.so RcppExports.o kMeans.o linearRegression.o loadDefaultPrediction.o randomForest.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-rcppmlpack-examples/00new/rcppmlpackexamples/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rcppmlpackexamples)
edd@paul:~/git/rcppmlpack-examples(master)$ Example after adding -DARMA_USE_CURRENT in src/Makevars{,.win} to PKG_CXXFLAGS: uses 15.0.1 without warnings
Details
edd@paul:~/git/rcppmlpack-examples(master)$ install.r
* installing *source* package found in current working directory ...
* installing *source* package ‘rcppmlpackexamples’ ...
** this is package ‘rcppmlpackexamples’ version ‘0.0.1’
** using staged installation
** libs
using C++ compiler: ‘g++ (Ubuntu 14.2.0-19ubuntu2) 14.2.0’
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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -DARMA_USE_CURRENT -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -DARMA_USE_CURRENT -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c kMeans.cpp -o kMeans.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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -DARMA_USE_CURRENT -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c linearRegression.cpp -o linearRegression.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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -DARMA_USE_CURRENT -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c loadDefaultPrediction.cpp -o loadDefaultPrediction.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' -I'/usr/local/lib/R/site-library/mlpack/include' -fopenmp -DARMA_USE_CURRENT -fpic -O3 -Wall -pipe -pedantic -Wno-parentheses -Wno-ignored-attributes -Wno-unused-function -c randomForest.cpp -o randomForest.o
ccache g++ -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -o rcppmlpackexamples.so RcppExports.o kMeans.o linearRegression.o loadDefaultPrediction.o randomForest.o -fopenmp -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-rcppmlpack-examples/00new/rcppmlpackexamples/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rcppmlpackexamples)
edd@paul:~/git/rcppmlpack-examples(master)$ So in the case of standard (and relatively simple) package all it takes is to add one #define to the compiler flags and all is well: the newer Armadillo is used, no warnings are seen.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
Uses the fix given in RcppCore/RcppArmadillo#476 to suppress the warning
eddelbuettel commentedon Nov 20, 2025
This issue can now be closed. We will of course continue to support packages using RcppArmadillo and greatly appreciate the many packages that did change and update.