ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

undefined reference to KDL::Rotation::Quaternion

asked 2018-03-12 07:28:01 -0500

dinesh gravatar image

updated 2018-03-12 23:57:52 -0500

I am using orocos toolchain 2.9, ros kinetic, ubunt u16.

CMakeFiles/localisation-component.dir/src/localisation-component.cpp.o: In function `Localisation::updateHook()':
localisation-component.cpp:(.text._ZN12Localisation10updateHookEv[_ZN12Localisation10updateHookEv]+0xd3): undefined reference to `KDL::Rotation::Quaternion(double, double, double, double)'
localisation-component.cpp:(.text._ZN12Localisation10updateHookEv[_ZN12Localisation10updateHookEv]+0xe6): undefined reference to `KDL::epsilon'
localisation-component.cpp:(.text._ZN12Localisation10updateHookEv[_ZN12Localisation10updateHookEv]+0x10b): undefined reference to `KDL::Rotation::GetRotAngle(KDL::Vector&, double) const'
collect2: error: ld returned 1 exit status
youbot-controller/CMakeFiles/localisation-component.dir/build.make:133: recipe for target '/home/robot/youbot_catkin_ws/devel/lib/orocos/gnulinux/youbot-controller/' failed
make[2]: *** [/home/robot/youbot_catkin_ws/devel/lib/orocos/gnulinux/youbot-controller/] Error 1
CMakeFiles/Makefile2:1273: recipe for target 'youbot-controller/CMakeFiles/localisation-component.dir/all' failed
make[1]: *** [youbot-controller/CMakeFiles/localisation-component.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

My CmakeLists.txt file is:

cmake_minimum_required(VERSION 2.8.3)

### ROS Dependencies ###
# Find the RTT-ROS package (this transitively includes the Orocos CMake macros)
find_package(catkin REQUIRED COMPONENTS




### Orocos Dependencies ###
# Note that orocos_use_package() does not need to be called for any dependency
# listed in the package.xml file


### Orocos Targets ###

orocos_component(localisation-component src/localisation-component.cpp)
target_link_libraries(localisation-component ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_library(my_library src/my_library.cpp)
# target_link_libraries(my_library ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_service(my_service src/my_service.cpp)
# target_link_libraries(my_service ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_plugin(my_plugin src/my_plugin.cpp)

# target_link_libraries(my_plugin ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_typekit(my_typekit src/my_typekit.cpp)
# target_link_libraries(my_typekit ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

### Orocos Package Exports and Install Targets ###

# Generate install targets for header files

orocos_install_headers(DIRECTORY include/${PROJECT_NAME})

# Export package information (replaces catkin_package() macro) 
  INCLUDE_DIRS include
  DEPENDS rtt_ros

the src file is:


#include <rtt/RTT.hpp>
#include <iostream>
#include <geometry_msgs/Pose2D.h>
#include <geometry_msgs/TransformStamped.h>
#include <kdl/frames.hpp>

class Localisation
    : public RTT::TaskContext
    geometry_msgs::TransformStamped tfs;
    RTT::OutputPort<geometry_msgs::Pose2D> outpose;
    Localisation(std::string const& name)
        : TaskContext(name, PreOperational)
        addPort("pose", outpose).doc("Contains latest Youbot Pose.");

    bool configureHook() {
        /** Check in here that we can call rtt_tf */
        return false;

    void updateHook() {
        try {
            /* tfs = rtt_tf and query the transform /odom to /base_footprint ... ; */
        } catch (...) {
        geometry_msgs::Pose2D pose;
        pose.x = tfs.transform.translation.x;
        pose.y = tfs.transform.translation.y;
        geometry_msgs::Quaternion qu = tfs.transform.rotation;
        KDL::Rotation rot = KDL::Rotation::Quaternion(qu.x, qu.y, qu.z, qu.w);
        KDL::Vector v;
        pose.theta = rot.GetRotAngle(v);

edit retag flag offensive close merge delete


So where do you link against kdl_parser libraries? Just find_package(..)ing that package is not enough.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-12 09:23:45 -0500 )edit

i tried like that also but still the same error. something problem with api version mismatch?

dinesh gravatar image dinesh  ( 2018-03-12 23:56:04 -0500 )edit

i tried like that also

you tried what? As always: show what you did.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-13 01:51:57 -0500 )edit

i've edited above question in CmakeLists.txt file. by adding find_package(orocos_kdl) find_package(kdl_parser) and target_link_libraries(localisation-component ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

dinesh gravatar image dinesh  ( 2018-03-13 06:09:18 -0500 )edit

I'm not too familiar with what ${USE_OROCOS_LIBRARIES} does exactly, but unless it automatically pulls in the libraries of kdl_parser and orocos_kdl, I would expect to still see linker errors.

Note also that this doesn't seem like a ROS question. At best one to ask of the OROCOS devs.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-13 06:14:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-03-14 07:25:52 -0500

The orocos_kdl_LIBRARIES are not picked up by catkin or orocos, so they are not part of ${catkin_LIBRARIES} or ${USE_OROCOS_LIBRARIES}. you need to add them to your target_link_libraries statement:

target_link_libraries(localisation-component ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES} ${orocos_kdl_LIBRARIES}),

your probably should do something similar for the include directories:

include_directories(${catkin_INCLUDE_DIRS} ${orocos_kdl_INCLUDE_DIRS}

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-03-12 07:28:01 -0500

Seen: 1,076 times

Last updated: Mar 14 '18