我正在尝试使用 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()'
Run Code Online (Sandbox Code Playgroud)
我添加到 CMakeLists.txt 的唯一代码是:
target_link_libraries(${PROJECT_NAME} yaml-cpp)
rosbuild_add_executable(image_test src/image_test.cpp)
Run Code Online (Sandbox Code Playgroud)
我在 Linux 中使用 fuerte。有人有什么解决办法吗?
编辑:我找到了我的解决方案!我更改了 CMakeLists.txt 以首先构建可执行文件,然后添加 yaml-cpp 库!
rosbuild_add_executable(image_test src/image_test.cpp)
target_link_libraries(image_test yaml-cpp)
Run Code Online (Sandbox Code Playgroud)
我的 CMakeLists.txt 中的这两行工作正常!
这些是链接器错误。确保链接到该库并包含其标头。CMakeLists.txt从您提供的链接来看,您的文件中似乎需要:
target_link_libraries(${PROJECT_NAME} yaml-cpp)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3260 次 |
| 最近记录: |