'Why armadillo changed after including RcppArmadillo?

I'm working on a RcppArmadillo package. Most part of my algorithm myfun() is implemented in a C++ source file, called myfun.cpp with a header file myfun.h providing some declarations. My algorithm is built on top of pure armadillo (i.e., it just includes armadillo not RcppArmadillo.h) and gsl. In RcppExports.cpp there is also a wrapper function _mypackager_myfun() to convert R objects and call myfun() to get its results.

When compiling my package with command R CMD INSTALL, an error "undefined external symbol referenced in _mypackager_myfun()" occurs always if I include my own header file in the RcppExports.cpp file like this:

// RcppExports.cpp
#include <RcppArmadillo.h>
#include <Rcpp.h>
#include "myfun.h"

However, everything goes well if myfun.h is included before RcppArmadillo.h like this:

// RcppExports.cpp
#include "hlmgwr.h"
#include <RcppArmadillo.h>
#include <Rcpp.h>

To what I know, file RcppArmadillo.h also includes the armadillo header. But why could the order of these header files affect linking of symbols? Are mat classes in armadillo and RcppArmadillo not the same?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source