Skip to content

[R-pkg-devel] SHLIB_OPENMP_*FLAGS in Makefiles

3 messages · Jarrett Phillips, Maxime Turgeon, Dirk Eddelbuettel

#
In checking my R package via devtools::check and devtools::check_built, I
received the following NOTE which I am unsure how to fix. My package
contains compiled code (via Rcpp). Within my .cpp file I have the following
line:

#define ARMA_DONT_PRINT_OPENMP_WARNING

Is this the issue?

checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... NOTE
  src/Makevars: SHLIB_OPENMP_CXXFLAGS is included in PKG_CXXFLAGS but
not in PKG_LIBS
  src/Makevars: SHLIB_OPENMP_CFLAGS is included in PKG_LIBS but
linking is by C++
  src/Makevars.win: SHLIB_OPENMP_CXXFLAGS is included in PKG_CXXFLAGS
but not in PKG_LIBS
  src/Makevars.win: SHLIB_OPENMP_CFLAGS is included in PKG_LIBS but
linking is by C++


Thanks.
#
The NOTE refers to Makevars and Makevars.win. The most logical place to start your investigation would be those two files. Do you have any reason to believe that they are *not* the culprits?

Max
#
On 15 April 2019 at 11:21, Jarrett Phillips wrote:
| In checking my R package via devtools::check and devtools::check_built, I
| received the following NOTE which I am unsure how to fix. My package
| contains compiled code (via Rcpp). Within my .cpp file I have the following
| line:
| 
| #define ARMA_DONT_PRINT_OPENMP_WARNING
| 
| Is this the issue?

No.
 
| checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... NOTE
|   src/Makevars: SHLIB_OPENMP_CXXFLAGS is included in PKG_CXXFLAGS but
| not in PKG_LIBS
|   src/Makevars: SHLIB_OPENMP_CFLAGS is included in PKG_LIBS but
| linking is by C++
|   src/Makevars.win: SHLIB_OPENMP_CXXFLAGS is included in PKG_CXXFLAGS
| but not in PKG_LIBS
|   src/Makevars.win: SHLIB_OPENMP_CFLAGS is included in PKG_LIBS but
| linking is by C++

R is now quite explicit about something is used to not complain about: a mix
of C and CXX flags used in the two listed files (as Maxime pointed out).

This is quite possibly due to the skeleton version of these files included in
older versions of RcppArmadillo.  We of course switched to a corrected one
once these warnings appeared, but we cannot fix the packages already out there.
"Better" versions are at

https://github.com/RcppCore/RcppArmadillo/blob/master/inst/skeleton/Makevars
https://github.com/RcppCore/RcppArmadillo/blob/master/inst/skeleton/Makevars.win

and in essence you just need these two updated lines:

PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) 
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

and we also recommend including

CXX_STD = CXX11

as the files do.

Hope this helps, Dirk