我收到以下错误:
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中添加一些东西,但我想我做错了。
所有想法?
答案 0 :(得分:3)
您需要在CMakeLists.txt中添加以下内容:
rosbuild_add_boost_directories()
rosbuild_link_boost(ndt_visualizer filesystem system)
有关详细信息,请参阅http://www.ros.org/wiki/rosbuild/CMakeLists#rosbuild_link_boost。
在你清单中的lflags或cflags中添加行会影响链接到你的其他包,而不是你链接其他包。
将来,根据ROS Answers
,Support Guidelines可以更好地询问ROS问题答案 1 :(得分:0)
就像一个小的跟进,我遇到了涉及文件状态和错误代码的未定义引用的问题。
问题出现了订购库链接(“更少依赖”库来自“更依赖”的库,至少与GCC相关)。我的项目使用了依赖于Boost.Filesystem和yaml-cpp的自定义库。在此之前,我将自定义库链接到boost库之后,但是没有用。我必须通过确保之后的提升相关来解决这个问题:
rosbuild_add_boost_directories()
rosbuild_add_executable(${PROJECT_NAME} ${SRCS})
target_link_libraries(${PROJECT_NAME} custom_lib yaml-cpp)
rosbuild_link_boost(${PROJECT_NAME} filesystem system)