koide3 / glim_ros2

27 stars 5 forks source link

colcon build error in ROS Iron #33

Closed HanLeqi0117 closed 2 weeks ago

HanLeqi0117 commented 2 weeks ago

Thank you for sharing a great project. I would like using this package for the localization of my autonomous robot.

When I was trying to use Colcon to build this package on Ubuntu22.04, ROS Iron, CUDA 12.2, I got an error like

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 to `gtsam::FixedLagSmoother::eraseKeyTimestampMap(std::vector<unsigned long, std::allocator<unsigned long> > 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 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 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 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&)'
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 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 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 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 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 to `gtsam::NonlinearFactor::rekey(std::vector<unsigned long, std::allocator<unsigned long> > 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 to `gtsam::FixedLagSmoother::eraseKeyTimestampMap(std::vector<unsigned long, std::allocator<unsigned long> > 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 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 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 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&)'
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 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 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 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 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 to `gtsam::NonlinearFactor::rekey(std::vector<unsigned long, std::allocator<unsigned long> > 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

This error looks like related with GTSAM and gtsam_points. So I check my libgtsam_points.so like

ldd /usr/local/lib/libgtsam_points.so

and get the result which is

    linux-vdso.so.1 (0x00007fff1ec61000)
    libboost_filesystem.so.1.74.0 => /lib/x86_64-linux-gnu/libboost_filesystem.so.1.74.0 (0x000071fae452b000)
    libgtsam_points_cuda.so => /usr/local/lib/libgtsam_points_cuda.so (0x000071fae2e00000)
    libgtsam.so.4 => /home/han/gtsam/build/gtsam/libgtsam.so.4 (0x000071fae2800000)
    libgtsam_unstable.so.4 => /opt/ros/iron/lib/x86_64-linux-gnu/libgtsam_unstable.so.4 (0x000071fae26e0000)
    libgomp.so.1 => /lib/x86_64-linux-gnu/libgomp.so.1 (0x000071fae44df000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x000071fae2400000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x000071fae4119000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x000071fae44bf000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000071fae2000000)
    libcudart.so.12 => /usr/local/cuda/lib64/libcudart.so.12 (0x000071fae1c00000)
    libboost_serialization.so.1.74.0 => /lib/x86_64-linux-gnu/libboost_serialization.so.1.74.0 (0x000071fae269e000)
    libboost_timer.so.1.74.0 => /lib/x86_64-linux-gnu/libboost_timer.so.1.74.0 (0x000071fae44b3000)
    libmetis-gtsam.so => /opt/ros/iron/lib/x86_64-linux-gnu/libmetis-gtsam.so (0x000071fae262f000)
    libtbb.so.12 => /lib/x86_64-linux-gnu/libtbb.so.12 (0x000071fae23b0000)
    /lib64/ld-linux-x86-64.so.2 (0x000071fae4585000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x000071fae44ac000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x000071fae44a7000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x000071fae44a2000)
    libboost_chrono.so.1.74.0 => /lib/x86_64-linux-gnu/libboost_chrono.so.1.74.0 (0x000071fae4497000)

My GTSAM version is installed by referencing to the repo of gtsam_points like

# Install gtsam
git clone https://github.com/borglab/gtsam
cd gtsam
git checkout 4.2a9

mkdir build && cd build
cmake .. \
  -DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \
  -DGTSAM_BUILD_TESTS=OFF \
  -DGTSAM_WITH_TBB=OFF \
  -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF

make -j$(nproc)
sudo make install

How could I fix this error? I look forward to your reply.

github-actions[bot] commented 2 weeks ago

Please re-open the issue in the GLIM main repository.

koide3 commented 2 weeks ago

Do NOT download and install the zip file! This is very suspicious response. Another guy posted the very same link within a different context. I'm reporting it to github.

https://github.com/koide3/glim_ext/issues/14