Question

I am trying to use the yaml-cpp and according to the wiki, it's a system dependency so we don't even need to change the CMakelists.txt or manifest.xml. However, when I compile the code, I still get errors like:

/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()'

The only code I've added to CMakeLists.txt are:

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

I am using fuerte in Linux. Any solutions anybody?

EDIT: I have found my solution! I changed my CMakeLists.txt to build the executable first then add the yaml-cpp library!

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

Those two lines in my CMakeLists.txt work fine!

Was it helpful?

Solution

Those are linker errors. Make sure you're linking to the library as well as including its headers. From the link you provided, it appears that in your CMakeLists.txt file, you need:

target_link_libraries(${PROJECT_NAME} yaml-cpp)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top