gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 05:08:57 24 4
gpt4 key购买 nike

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

最佳答案

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

target_link_libraries(${PROJECT_NAME} yaml-cpp)

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

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