gpt4 book ai didi

c++ - ROS Linking errors using boost::filesystem library 在linux下使用C++

转载 作者:行者123 更新时间:2023-11-30 03:00:38 26 4
gpt4 key购买 nike

我收到以下错误:

CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::filesystem3::path::codecvt()':
/usr/include/boost/filesystem/v3/path.hpp:377: undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `directory_iterator':
/usr/include/boost/filesystem/v3/operations.hpp:594: undefined reference to `boost::filesystem3::detail::directory_iterator_construct(boost::filesystem3::directory_iterator&, boost::filesystem3::path const&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::filesystem3::path::codecvt()':
/usr/include/boost/filesystem/v3/path.hpp:377: undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `path<boost::filesystem3::directory_entry>':
/usr/include/boost/filesystem/v3/path.hpp:134: undefined reference to `boost::filesystem3::path_traits::dispatch(boost::filesystem3::directory_entry const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::codecvt<wchar_t, char, __mbstate_t> const&)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `is_directory':
/usr/include/boost/filesystem/v3/operations.hpp:223: undefined reference to `boost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::iterator_facade<boost::filesystem3::directory_iterator, boost::filesystem3::directory_entry, boost::single_pass_traversal_tag, boost::filesystem3::directory_entry&, int>::operator++()':
/usr/include/boost/filesystem/v3/operations.hpp:630: undefined reference to `boost::filesystem3::detail::directory_iterator_increment(boost::filesystem3::directory_iterator&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `boost::filesystem3::path::codecvt()':
/usr/include/boost/filesystem/v3/path.hpp:377: undefined reference to `boost::filesystem3::path::wchar_t_codecvt_facet()'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `is_directory':
/usr/include/boost/filesystem/v3/operations.hpp:223: undefined reference to `boost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code*)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `~dir_itr_imp':
/usr/include/boost/filesystem/v3/operations.hpp:563: undefined reference to `boost::filesystem3::detail::dir_itr_close(void*&, void*&)'
/usr/include/boost/filesystem/v3/operations.hpp:563: undefined reference to `boost::filesystem3::detail::dir_itr_close(void*&, void*&)'
CMakeFiles/ndt_visualiser.dir/src/fromFile.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'

我看过不少有类似错误的帖子。在几乎所有这些帖子(例如 Linking Boost Library in Linux)中,解决方案似乎是,您需要添加 -lboost_filesystem 和 -lboost_system 标志。我试过将它们作为 lflags 或 cflags 添加到 manifest.xml,但这绝对没有任何改变。我已经尝试在我的包的 CMakeLists.txt 中添加一些东西,但我想我做错了。

有什么想法吗?

最佳答案

您需要将如下行添加到您的 CMakeLists.txt:

rosbuild_add_boost_directories()
rosbuild_link_boost(ndt_visualizer filesystem system)

参见 http://www.ros.org/wiki/rosbuild/CMakeLists#rosbuild_link_boost了解更多详情。

向您 list 中的 lflags 或 cflags 添加行会影响链接到您的包的其他包,而不是您链接到其他包的包。

以后ROS的问题最好在ROS Answers上提问根据 Support Guidelines

关于c++ - ROS Linking errors using boost::filesystem library 在linux下使用C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11808668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com