【问题标题】:Error Using yaml-cpp in ROS?在 ROS 中使用 yaml-cpp 时出错?
【发布时间】:2013-04-05 02:52:18
【问题描述】:

我正在尝试使用 yaml-cpp,根据wiki,它是一个系统依赖项,因此我们甚至不需要更改 CMakelists.txt 或 manifest.xml。但是,当我编译代码时,我仍然会收到如下错误:

/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:53: undefined reference to `YAML::Parser::Parser(std::basic_istream<char, std::char_traits<char> >&)'
/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:54: undefined reference to `YAML::Node::Node()'
/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:92: undefined reference to `YAML::Node::~Node()'
/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:92: undefined reference to `YAML::Parser::~Parser()'
/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:92: undefined reference to `YAML::Node::~Node()'
/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:92: undefined reference to `YAML::Parser::~Parser()'
/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:92: undefined reference to `YAML::Node::~Node()'
/home/aramus/fuerte_workspace/sandbox/image_test/src/image_test.cpp:92: undefined reference to `YAML::Parser::~Parser()'

我添加到 CMakeLists.txt 的唯一代码是:

target_link_libraries(${PROJECT_NAME} yaml-cpp)
rosbuild_add_executable(image_test src/image_test.cpp)

我在 Linux 中使用 fuerte。有什么解决方案吗?

编辑: 我找到了我的解决方案!我更改了我的 CMakeLists.txt 以先构建可执行文件,然后添加 yaml-cpp 库!

rosbuild_add_executable(image_test src/image_test.cpp)
target_link_libraries(image_test yaml-cpp)

我的 CMakeLists.txt 中的这两行工作正常!

【问题讨论】:

    标签: yaml-cpp ros


    【解决方案1】:

    这些是链接器错误。确保您链接到库并包括其标题。从您提供的链接看来,在您的 CMakeLists.txt 文件中,您需要:

    target_link_libraries(${PROJECT_NAME} yaml-cpp)
    

    【讨论】:

    • 谢谢,我在最后添加了那行,现在它可以创造奇迹了!我最初在 rosbuild_add_executable 代码之前就有了它,这让我大吃一惊。
    猜你喜欢
    • 1970-01-01
    • 2017-10-09
    • 2018-10-13
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-27
    • 1970-01-01
    相关资源
    最近更新 更多