koide3 / glim

GLIM: versatile and extensible range-based 3D localization and mapping framework
MIT License
509 stars 64 forks source link

Build error in ROS2 #91

Closed Shaswat2001 closed 1 week ago

Shaswat2001 commented 1 week ago

I tried building glim_ros2 on Ubuntu 22.04 and ROS2 humble without CUDA. But get the following error

Cmake Error

Starting >>> glim_ros --- stderr: glim_ros
/usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::JacobianFactor::updateHessian(std::vector<unsigned long, std::allocator<unsigned long> > const&, gtsam::SymmetricBlockMatrix*) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::FixedLagSmoother::eraseKeyTimestampMap(std::vector<unsigned long, std::allocator > const&)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::NonlinearFactor::rekey(std::vector<unsigned long, std::allocator<unsigned long> > const&) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::EliminateableFactorGraph::marginalMultifrontalBayesNet(boost::variant<gtsam::Ordering const&, std::vector<unsigned long, std::allocator > const&>, std::function<std::pair<boost::shared_ptr, boost::shared_ptr > (gtsam::GaussianFactorGraph const&, gtsam::Ordering const&)> const&, boost::optional<gtsam::VariableIndex const&>) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::HessianFactor::HessianFactor(std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const&, std::vector<Eigen::Matrix<double, -1, 1, 0, -1, 1>, std::allocator<Eigen::Matrix<double, -1, 1, 0, -1, 1> > > const&, double)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::PrintKeyVector(std::vector<unsigned long, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::function<std::cxx11::basic_string<char, std::char_traits, std::allocator > (unsigned long)> const&)' collect2: error: ld returned 1 exit status gmake[2]: [CMakeFiles/offline_viewer.dir/build.make:272: offline_viewer] エラー 1 gmake[1]: [CMakeFiles/Makefile2:281: CMakeFiles/offline_viewer.dir/all] エラー 2 gmake[1]: 未完了のジョブを待っています.... /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::FixedLagSmoother::eraseKeyTimestampMap(std::vector<unsigned long, std::allocator<unsigned long> > const&)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::HessianFactor::HessianFactor(std::vector<unsigned long, std::allocator > const&, std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const&, std::vector<Eigen::Matrix<double, -1, 1, 0, -1, 1>, std::allocator<Eigen::Matrix<double, -1, 1, 0, -1, 1> > > const&, double)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::PrintKeyVector(std::vector<unsigned long, std::allocator<unsigned long> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (unsigned long)> const&)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::JacobianFactor::updateHessian(std::vector<unsigned long, std::allocator > const&, gtsam::SymmetricBlockMatrix) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::EliminateableFactorGraph<gtsam::GaussianFactorGraph>::marginalMultifrontalBayesNet(boost::variant<gtsam::Ordering const&, std::vector<unsigned long, std::allocator<unsigned long> > const&>, std::function<std::pair<boost::shared_ptr<gtsam::GaussianConditional>, boost::shared_ptr<gtsam::GaussianFactor> > (gtsam::GaussianFactorGraph const&, gtsam::Ordering const&)> const&, boost::optional<gtsam::VariableIndex const&>) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::NonlinearFactor::rekey(std::vector<unsigned long, std::allocator > const&) const' collect2: error: ld returned 1 exit status gmake[2]: ** [CMakeFiles/glim_rosnode.dir/build.make:271: glim_rosnode] エラー 1 gmake[1]: [CMakeFiles/Makefile2:200: CMakeFiles/glim_rosnode.dir/all] エラー 2 /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::JacobianFactor::updateHessian(std::vector<unsigned long, std::allocator<unsigned long> > const&, gtsam::SymmetricBlockMatrix*) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::FixedLagSmoother::eraseKeyTimestampMap(std::vector<unsigned long, std::allocator > const&)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::NonlinearFactor::rekey(std::vector<unsigned long, std::allocator<unsigned long> > const&) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::EliminateableFactorGraph::marginalMultifrontalBayesNet(boost::variant<gtsam::Ordering const&, std::vector<unsigned long, std::allocator > const&>, std::function<std::pair<boost::shared_ptr, boost::shared_ptr > (gtsam::GaussianFactorGraph const&, gtsam::Ordering const&)> const&, boost::optional<gtsam::VariableIndex const&>) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::HessianFactor::HessianFactor(std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const&, std::vector<Eigen::Matrix<double, -1, 1, 0, -1, 1>, std::allocator<Eigen::Matrix<double, -1, 1, 0, -1, 1> > > const&, double)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::PrintKeyVector(std::vector<unsigned long, std::allocator > const&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::function<std::cxx11::basic_string<char, std::char_traits, std::allocator > (unsigned long)> const&)' collect2: error: ld returned 1 exit status gmake[2]: [CMakeFiles/validator_node.dir/build.make:271: validator_node] エラー 1 gmake[1]: [CMakeFiles/Makefile2:254: CMakeFiles/validator_node.dir/all] エラー 2 /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::FixedLagSmoother::eraseKeyTimestampMap(std::vector<unsigned long, std::allocator<unsigned long> > const&)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::HessianFactor::HessianFactor(std::vector<unsigned long, std::allocator > const&, std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const&, std::vector<Eigen::Matrix<double, -1, 1, 0, -1, 1>, std::allocator<Eigen::Matrix<double, -1, 1, 0, -1, 1> > > const&, double)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::PrintKeyVector(std::vector<unsigned long, std::allocator<unsigned long> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (unsigned long)> const&)' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::JacobianFactor::updateHessian(std::vector<unsigned long, std::allocator > const&, gtsam::SymmetricBlockMatrix*) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference to gtsam::EliminateableFactorGraph<gtsam::GaussianFactorGraph>::marginalMultifrontalBayesNet(boost::variant<gtsam::Ordering const&, std::vector<unsigned long, std::allocator<unsigned long> > const&>, std::function<std::pair<boost::shared_ptr<gtsam::GaussianConditional>, boost::shared_ptr<gtsam::GaussianFactor> > (gtsam::GaussianFactorGraph const&, gtsam::Ordering const&)> const&, boost::optional<gtsam::VariableIndex const&>) const' /usr/bin/ld: /usr/local/lib/libgtsam_points.so: undefined reference togtsam::NonlinearFactor::rekey(std::vector<unsigned long, std::allocator > const&) const' collect2: error: ld returned 1 exit status gmake[2]: [CMakeFiles/glim_rosbag.dir/build.make:271: glim_rosbag] エラー 1 gmake[1]: [CMakeFiles/Makefile2:227: CMakeFiles/glim_rosbag.dir/all] エラー 2 gmake: *** [Makefile:146: all] エラー 2

Failed <<< glim_ros [2.44s, exited with code 2]

Summary: 0 packages finished [2.94s] 1 package failed: glim_ros 1 package had stderr output: glim_ros

I have followed the exact steps in the installation page. But the issue still exists. How to solve it?

Shaswat2001 commented 1 week ago

I guess this was something related to my system only. Because I was able to build the package on a different machines successfully.

koide3 commented 5 days ago

These errors are typically caused by installing a wrong version of GTSAM. Please check the installed GTSAM version with:

ls /usr/local/lib/libgtsam*
# /usr/local/lib/libgtsam_points_cuda.so  /usr/local/lib/libgtsam.so    /usr/local/lib/libgtsam.so.4.2.0     /usr/local/lib/libgtsam_unstable.so.4
# /usr/local/lib/libgtsam_points.so       /usr/local/lib/libgtsam.so.4  /usr/local/lib/libgtsam_unstable.so  /usr/local/lib/libgtsam_unstable.so.4.2.0

If there exist libgtsam.so.4.3a0 or something similar, remove them and re-install GTSAM 4.2a9.