yaml-cpp - 在 ROS 中使用 yaml-cpp 时出错?

标签 yaml-cpp ros

我正在尝试使用 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 中的这两行工作正常!

最佳答案

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

target_link_libraries(${PROJECT_NAME} yaml-cpp)

关于yaml-cpp - 在 ROS 中使用 yaml-cpp 时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15825103/

相关文章:

yaml-cpp - 包括没有可用 Boost 的 yaml-cpp -

opencv - ROS Roboearth Ubuntu 12.04 vision_opencv 链接错误

c++ - 使用消息在 ROS 上发送 C 数组

ubuntu-18.04 - Ubuntu 18.04 中的 ROS Melodic 安​​装 dkms 错误 - 错误!内核 : 5. 4.0-89-generic (x86_64) 上构建的模块返回状态错误

ros - 拯救新世界时凉亭卡住

c++ - 在 YAML 文件中将项目附加到 map

c++ - 如何为 YAML::Emitter 重载 << 运算符以序列化包含另一个自定义类的 vector 的自定义类

c++ - yaml-cpp 节点诊断有意义的错误

ubuntu-12.04 - 如何从 bagfile 中提取图像帧?

yaml-cpp - 如何将 yaml 节点数组读入 std::vector