kalman-cpp
kalman-cpp copied to clipboard
Compilation Error
I'm getting the follow error when compiling the code.
KalmanTest.cpp:(.text+0x71e): undefined reference to KalmanFilter::KalmanFilter(double, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&)' /usr/bin/ld: KalmanTest.cpp:(.text+0x837): undefined reference to
KalmanFilter::init(double, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)'
/usr/bin/ld: KalmanTest.cpp:(.text+0x9b0): undefined reference to `KalmanFilter::update(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)'
collect2: error: ld returned 1 exit status
Hi, I also getting the same error is there any solution for it?
: /usr/local/include/eigen3/Eigen/src/Core/Product.h:97: Eigen::Product<Lhs, Rhs, Option>::Product(const Lhs&, const Rhs&) [with _Lhs = Eigen::Matrix<double, -1, -1>; _Rhs = Eigen::Matrix<double, -1, -1>; int Option = 0; Eigen::Product<Lhs, Rhs, Option>::Lhs = Eigen::Matrix<double, -1, -1>; Eigen::Product<Lhs, Rhs, Option>::Rhs = Eigen::Matrix<double, -1, -1>]: Assertion `lhs.cols() == rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"' failed.
That's because you are only trying to compile the kalman-test.cpp
file which references kalman.cpp
implicitly. If you carefully look through the CMakeLists.txt
file (which also needs modifications btw), in the line set(SOURCE_FILES kalman.cpp kalman-test.cpp)
we notice that both of these are to be compiled simultaneously in order to run the test-case presented in kalman-test
file. So if you are not using CMake for compilation, just use the command g++ kalman.cpp kalman-test.cpp
, then run ./a.exe
which will give the estimated state vector at each time step and a host of other things.
This closes https://github.com/hmartiro/kalman-cpp/issues/7#issue-485822252