0

In a function that doesn't keep the parameters immutable, with potentially large size, therefore pass by reference, defined to be inline, i get the error undefined reference at compile time, removing the inlining makes it compile. here is my declaration:

  inline Eigen::VectorXd
  ForwardDynamics(const Eigen::VectorXd &, const Eigen::VectorXd&);

definition:

inline Eigen::VectorXd
Kinetics::ForwardDynamics(const Eigen::VectorXd &taulist,
                          const Eigen::VectorXd &Ftip) {
  Eigen::VectorXd tau = taulist;
  Eigen::VectorXd Ft = Ftip;
  

  //... code is a bit long ...
  // but taulist, Ftip never used.
  // .........

  return res;
}

called from the test case, i get the following error at compile time:

undefined reference to `Kinetics::ForwardDynamics(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)'

an analogous example like

#include <iostream>

struct Info {
  int i;
};

typedef Info info;

class A {
public:
  A() {
  }

  inline void display_info(const info &f) {
    std::cout << f.i << std::endl;
  }
};

int main(int argc, char **args) {
  A a;
  info f{2408};
  a.display_info(f);
}

would compile fine, so the problem clearly from the test environment i'm using which is gtest, or the Eigen library itself, considering Eigen, and gtest as black box, what do you expect the reason of this problem?

Error
  • 820
  • 1
  • 11
  • 34

0 Answers0