Linking CXX executable error, undefined reference to TinyXml

asked 2019-03-08 04:30:32 -0600

AaronM gravatar image

updated 2019-03-08 05:30:48 -0600

gvdhoorn gravatar image

Hello everyone,

I am trying to compile catkin_make on this project more than a month now that is why I am desperately putting it up to the forum, I would be very grateful if you could help me with this somehow, I downloaded a repository from github: and could compile it with ROS Kinetic but since I experienced some issues in the code I asked the author in what environment was he working with it, so I installed ROS Indigo in the suitable ubuntu version and I cant compile the same code ever since. I get a message from catkin_make:

Linking CXX executable /home/aron/catkin_ws/devel/lib/br_motor_driver/ros_driver
[ 14%] Built target _cable_rob_generate_messages_check_deps_cable_msgs
[ 14%] Built target sensor_msgs_generate_messages_cpp
[ 14%] Built target std_msgs_generate_messages_cpp
[ 14%] Built target geometry_msgs_generate_messages_cpp
[ 14%] Built target trajectory_msgs_generate_messages_cpp
/home/aron/catkin_ws/devel/lib/ undefined reference to `vtable for TiXmlDocument'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlNode::~TiXmlNode()'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlElement::QueryDoubleAttribute(char const*, double*) const'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlElement::SetAttribute(std::string const&, std::string const&)'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlDocument::Accept(TiXmlVisitor*) const'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlNode::FirstChildElement(char const*) const'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlElement::TiXmlElement(std::string const&)'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlDocument::TiXmlDocument()'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlElement::QueryBoolAttribute(char const*, bool*) const'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlNode::LinkEndChild(TiXmlNode*)'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlDocument::Parse(char const*, TiXmlParsingData*, TiXmlEncoding)'
/home/aron/catkin_ws/devel/lib/ undefined reference to `vtable for TiXmlPrinter'
/home/aron/catkin_ws/devel/lib/ undefined reference to `TiXmlElement::TiXmlElement(char const*)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/aron/catkin_ws/devel/lib/br_motor_driver/ros_driver] Error 1
make[1]: *** [cable_driven_robot/br_motor_driver/CMakeFiles/ros_driver.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 14%] Built target _cable_rob_generate_messages_check_deps_robot_cables_msgs
make: *** [all] Error 2
Invoking "make -j2 -l2" failed

I searched a lot of forums where I followed there advice, by installing the tinyxml library again, installed aptitude and installed tinyxml as a package, still didnt work, I installed various versions of tinyxml, still no success I get the same message where it wont be able to create the executable ros_driver I checked the CmakeLists.txt file and followed this tutorial: to see if there is some error but I couldn't find any, it should work just as it works in ROS Kinetic :/

Also if I run:

# apt search tinyxml

Sorting... Done
Full Text Search... Done
libtinyxml-dev/trusty,now 2.6.2-2 amd64 [installed]
  TinyXml library - header and static library

libtinyxml-doc/trusty 2.6.2-2 all
  TinyXml library - documentation files

libtinyxml2-0.0.0/trusty ...
edit retag flag offensive close merge delete


There appear to be some lines in your CMakeLists.txt that I would assume are left over comments. Example:

Specify additional locations of header files
Your package locations should be listed before other locations

Can you verify?

gvdhoorn gravatar imagegvdhoorn ( 2019-03-08 05:31:48 -0600 )edit

Just to get you going: on Indigo, change the order of the target_link_libraries(..) statements such that ${TinyXML_LIBRARIES} comes before ${catkin_LIBRARIES}.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-08 06:08:14 -0600 )edit

I installed various versions of tinyxml,

you might also want to make sure you still have a sane build environment after all of that.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-08 06:09:01 -0600 )edit

Thank you for your response, yes those lines should be commented, that is a mistake I made when I was pasting it here, sorry, but in the code I have it in comments :) Your suggestion worked, I only needed to change the order, with ${TinyXML_LIBRARIES} coming first and ${catkin_LIBRARIES} coming second, it is funny, that after all the hassle I made the solution is this simple, thank you! I wouldn't solve it without your help, especially because I am still relatively new to ROS :D Thank you very much :D Hope it helps other users as well; if they encounter a similar problem :)

AaronM gravatar imageAaronM ( 2019-03-10 14:10:57 -0600 )edit