错误在ROS中使用yaml-cpp?

时间:2013-04-05 02:52:19

标签: 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中的那两行正常工作!

1 个答案:

答案 0 :(得分:3)

这些是链接器错误。确保您链接到库以及包含其标题。在您提供的链接中,您需要在CMakeLists.txt文件中显示:

target_link_libraries(${PROJECT_NAME} yaml-cpp)