Search code examples
rpackagercppdevtools

Building an R package: Error "translate_lapack.hpp:1247: undefined reference to `ilaenv_'"


When I run devtools::document() on my R package (which includes C++ code), I get multiple errors of the type

C:/Users/Lennart/Documents/R/win-library/4.0/RcppArmadillo/include/armadillo_bits/translate_lapack.hpp:1247: undefined reference to `ilaenv_'

Do you have any idea how to fix this?


Solution

  • This is an incomplete question---we have no code to go by, and have no idea how you set your package up.

    Note that for RcppArmadillo you must use the snippets provided here (and automatically included by RcppArmadillo.package.skeleton()) in order to get the correct files src/Makevars and src/Makevars.win which have

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

    which ensures working OpenMP (if R has it on the architecture) and working LAPACK / BLAS.