kalman-cpp icon indicating copy to clipboard operation
kalman-cpp copied to clipboard

Compilation Error

Open celeritasracing opened this issue 5 years ago • 3 comments

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

celeritasracing avatar Aug 27 '19 13:08 celeritasracing

Hi, I also getting the same error is there any solution for it?

VbsmRobotic avatar Jan 27 '22 16:01 VbsmRobotic

: /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.

VbsmRobotic avatar Jan 27 '22 16:01 VbsmRobotic

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

mechandansinha avatar Sep 02 '22 05:09 mechandansinha