Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Calling ROS libraries from external CPP

I want to call the ROS libraries (shared object .so files) from external CPP program. Below are the ROS libraries-

  1. /opt/ros/indigo/lib/libkdl_parser.so
  2. /opt/ros/indigo/lib/liborocos-kdl.so.1.3.0

The main code i.e., test.cpp looks like following-

#include <iostream>
#include <kdl/jntarray.hpp>
#include <kdl/chaindynparam.hpp>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/jntspaceinertiamatrix.hpp>

int main(int argc, char** argv)
{
    std::string urdf_file = "robot.urdf";
    std::string base_link = "base";
    std::string tip_link = "end_effector";

    KDL::Tree tree;
    if (!kdl_parser::treeFromFile(urdf_file, tree)) {
        printf("Failed to construct kdl tree\n");
        return -1;
    }

    KDL::Chain chain;
    if (!tree.getChain(base_link, tip_link, chain))
        printf("Couldn't find chain from %s to %s\n", base_link.c_str(), tip_link.c_str());

    KDL::ChainDynParam dyn(chain, KDL::Vector::Zero());

    KDL::JntArray q(chain.getNrOfJoints()); //dummy value
    KDL::JntSpaceInertiaMatrix H(chain.getNrOfJoints());
    dyn.JntToMass(q, H);

    printf("(0,0) element of Inertia Matrix %f\n", H(0,0));
    return 0;
}

The robot.urdf is kept along with test.cpp and headers are kept in a sub-directory. Below is the directory structure-

ravi@lab:~/test/calling_ros_lib$ tree
.
├── include
│   ├── kdl
│   │   ├── articulatedbodyinertia.hpp
│   │   ├── chaindynparam.hpp
│   │   ├── chain.hpp
│   │   ├── chainidsolver.hpp
│   │   ├── chainidsolver_recursive_newton_euler.hpp
│   │   ├── config.h
│   │   ├── frames.hpp
│   │   ├── frames.inl
│   │   ├── jacobian.hpp
│   │   ├── jntarray.hpp
│   │   ├── jntspaceinertiamatrix.hpp
│   │   ├── joint.hpp
│   │   ├── rigidbodyinertia.hpp
│   │   ├── rotationalinertia.hpp
│   │   ├── segment.hpp
│   │   ├── tree.hpp
│   │   └── utilities
│   │       ├── kdl-config.h
│   │       └── utility.h
│   ├── kdl_parser
│   │   └── kdl_parser.hpp
│   ├── urdf
│   │   └── urdfdom_compatibility.h
│   └── urdf_model
│       └── model.h
├── robot.urdf
└── test.cpp

6 directories, 23 files

I used gcc to compile the test.cpp with following command-

gcc test.cpp -Iinclude/ -I/usr/include/eigen3/ -l/opt/ros/indigo/lib/libkdl_parser.so -l/opt/ros/indigo/lib/liborocos-kdl.so.1.3.0 -o test

but it is not working, since there are few more dependecies to satisfy. Below is the complete error trace-

ravi@lab:~/test/calling_ros_lib$ gcc test.cpp -Iinclude/ -I/usr/include/eigen3/ -l/opt/ros/indigo/lib/libkdl_parser.so -l/opt/ros/indigo/lib/liborocos-kdl.so.1.3.0 -o test
In file included from include/urdf_model/model.h:43:0,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf/urdfdom_compatibility.h:78:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<ModelInterface> ModelInterfaceSharedPtr;
         ^
include/urdf/urdfdom_compatibility.h:79:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const ModelInterface> ModelInterfaceConstSharedPtr;
         ^
include/urdf/urdfdom_compatibility.h:80:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<ModelInterface> ModelInterfaceWeakPtr;
         ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h:51:1: error: expected class-name before ‘{’ token
 {
 ^
In file included from test.cpp:11:0:
include/kdl_parser/kdl_parser.hpp:80:30: error: ‘ModelInterface’ in namespace ‘urdf’ does not name a type
 bool treeFromUrdfModel(const urdf::ModelInterface& robot_model, KDL::Tree& tree);
                              ^
include/kdl_parser/kdl_parser.hpp:80:52: error: ISO C++ forbids declaration of ‘robot_model’ with no type [-fpermissive]
 bool treeFromUrdfModel(const urdf::ModelInterface& robot_model, KDL::Tree& tree);
                                                    ^
ravi@lab:~/test/calling_ros_lib$

How to call these libraries from an external CPP without using ROS?

Calling ROS libraries from external CPP

I want to call the ROS libraries (shared object .so files) from external CPP program. Below are the ROS libraries-

  1. /opt/ros/indigo/lib/libkdl_parser.so
  2. /opt/ros/indigo/lib/liborocos-kdl.so.1.3.0

The main code i.e., test.cpp looks like following-

#include <iostream>
#include <kdl/jntarray.hpp>
#include <kdl/chaindynparam.hpp>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/jntspaceinertiamatrix.hpp>

int main(int argc, char** argv)
{
    std::string urdf_file = "robot.urdf";
    std::string base_link = "base";
    std::string tip_link = "end_effector";

    KDL::Tree tree;
    if (!kdl_parser::treeFromFile(urdf_file, tree)) {
        printf("Failed to construct kdl tree\n");
        return -1;
    }

    KDL::Chain chain;
    if (!tree.getChain(base_link, tip_link, chain))
        printf("Couldn't find chain from %s to %s\n", base_link.c_str(), tip_link.c_str());

    KDL::ChainDynParam dyn(chain, KDL::Vector::Zero());

    KDL::JntArray q(chain.getNrOfJoints()); //dummy value
    KDL::JntSpaceInertiaMatrix H(chain.getNrOfJoints());
    dyn.JntToMass(q, H);

    printf("(0,0) element of Inertia Matrix %f\n", H(0,0));
    return 0;
}

The robot.urdf is kept along with test.cpp and headers are kept in a sub-directory. Below is the directory structure-

ravi@lab:~/test/calling_ros_lib$ test@test:~/Desktop/calll/calling_so$ tree
.
├── robot.urdf
├── errors
├── include
│   ├── kdl
│   │   ├── articulatedbodyinertia.hpp
│   │   ├── chaindynparam.hpp
│   │   ├── chain.hpp
│   │   ├── chainidsolver.hpp
│   │   ├── chainidsolver_recursive_newton_euler.hpp
│   │   ├── config.h
│   │   ├── frames.hpp
│   │   ├── frames.inl
│   │   ├── jacobian.hpp
│   │   ├── jntarray.hpp
│   │   ├── jntspaceinertiamatrix.hpp
│   │   ├── joint.hpp
│   │   ├── rigidbodyinertia.hpp
│   │   ├── rotationalinertia.hpp
│   │   ├── segment.hpp
│   │   ├── tree.hpp
│   │   └── utilities
│   │       ├── kdl-config.h
│   │       └── utility.h
│   ├── kdl_parser
│   │   └── kdl_parser.hpp
│   ├── urdf
│   │   ├── model.h
│   │   └── urdfdom_compatibility.h
│   ├── urdf_exception
│   │   └── exception.h
│   └── urdf_model
│       ├── color.h
│       ├── joint.h
│       ├── link.h
│       ├── model.h
│       ├── pose.h
│       ├── types.h
│       └── model.h
utils.h
├── robot.urdf
shared
│   ├── libkdl_parser.so
│   ├── liborocos-kdl.so -> liborocos-kdl.so.1.4
│   ├── liborocos-kdl.so.1.4 -> liborocos-kdl.so.1.4.0
│   └── liborocos-kdl.so.1.4.0
└── test.cpp

6 8 directories, 23 36 files

I used gcc to compile the test.cpp with following command-

gcc test.cpp -Iinclude/ -I/usr/include/eigen3/ -l/opt/ros/indigo/lib/libkdl_parser.so -l/opt/ros/indigo/lib/liborocos-kdl.so.1.3.0 -Lshared/ -lkdl_parser.so -lorocos-kdl.so -o test

but it is not working, since there are few more dependecies to satisfy. Below is the complete error trace-

ravi@lab:~/test/calling_ros_lib$ test@test:~/Desktop/calll/calling_so$  gcc test.cpp -Iinclude/ -I/usr/include/eigen3/ -l/opt/ros/indigo/lib/libkdl_parser.so -l/opt/ros/indigo/lib/liborocos-kdl.so.1.3.0 -Lshared/ -lkdl_parser.so -lorocos-kdl.so -o test
In file included from include/urdf_model/model.h:43:0,
include/urdf_model/joint.h:43:0,
                 from include/urdf_model/link.h:44,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf/urdfdom_compatibility.h:78:9: include/urdf_model/pose.h: In member function ‘void urdf::Vector3::init(const string&)’:
include/urdf_model/pose.h:78:25: error: ‘stod’ is not a member of ‘std’
           xyz.push_back(std::stod(pieces[i]));
                         ^
In file included from include/urdf_model/joint.h:43:0,
                 from include/urdf_model/link.h:44,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/pose.h:90:42: error: ‘to_string’ is not a member of ‘std’
       throw ParseError("Parser found " + std::to_string(xyz.size())  + " elements but 3 expected while parsing vector [" + vector_str + "]");
                                          ^
In file included from include/urdf_model/joint.h:44:0,
                 from include/urdf_model/link.h:44,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/types.h: At global scope:
include/urdf_model/types.h:51:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<ModelInterface> ModelInterfaceSharedPtr;
         ^
include/urdf/urdfdom_compatibility.h:79:9: std::shared_ptr<double> DoubleSharedPtr;
         ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const ModelInterface> ModelInterfaceConstSharedPtr;
         ^
include/urdf/urdfdom_compatibility.h:80:9: error: ‘weak_ptr’ std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:53:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Box);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<ModelInterface> ModelInterfaceWeakPtr;
std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:53:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Box);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:53:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Box);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:54:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Collision);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:54:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Collision);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:54:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Collision);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:55:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Cylinder);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:55:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Cylinder);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:55:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Cylinder);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:56:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Geometry);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:56:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Geometry);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:56:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Geometry);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:57:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Inertial);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:57:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Inertial);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:57:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Inertial);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:58:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Joint);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:58:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Joint);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:58:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Joint);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:59:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointCalibration);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:59:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointCalibration);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:59:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointCalibration);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:60:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointDynamics);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:60:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointDynamics);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:60:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointDynamics);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:61:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointLimits);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:61:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointLimits);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:61:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointLimits);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:62:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointMimic);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:62:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointMimic);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:62:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointMimic);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:63:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointSafety);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:63:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointSafety);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:63:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointSafety);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:64:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Link);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:64:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Link);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:64:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Link);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:65:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Material);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:65:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Material);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:65:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Material);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:66:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Mesh);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:66:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Mesh);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:66:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Mesh);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:67:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Sphere);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:67:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Sphere);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:67:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Sphere);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:68:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Visual);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:68:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Visual);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:68:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Visual);
 ^
include/urdf_model/types.h:72:1: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 std::shared_ptr<T> const_pointer_cast(std::shared_ptr<U> const & r)
 ^
include/urdf_model/types.h:78:1: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 std::shared_ptr<T> dynamic_pointer_cast(std::shared_ptr<U> const & r)
 ^
include/urdf_model/types.h:84:1: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 std::shared_ptr<T> static_pointer_cast(std::shared_ptr<U> const & r)
 ^
In file included from include/urdf_model/link.h:44:0,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/joint.h:141:3: error: ‘DoubleSharedPtr’ does not name a type
   DoubleSharedPtr rising, falling;
   ^
include/urdf_model/joint.h:199:3: error: ‘JointDynamicsSharedPtr’ does not name a type
   JointDynamicsSharedPtr dynamics;
   ^
include/urdf_model/joint.h:202:3: error: ‘JointLimitsSharedPtr’ does not name a type
   JointLimitsSharedPtr limits;
   ^
include/urdf_model/joint.h:205:3: error: ‘JointSafetySharedPtr’ does not name a type
   JointSafetySharedPtr safety;
   ^
include/urdf_model/joint.h:208:3: error: ‘JointCalibrationSharedPtr’ does not name a type
   JointCalibrationSharedPtr calibration;
   ^
include/urdf_model/joint.h:211:3: error: ‘JointMimicSharedPtr’ does not name a type
   JointMimicSharedPtr mimic;
   ^
include/urdf_model/joint.h: In member function ‘void urdf::Joint::clear()’:
include/urdf_model/joint.h:219:11: error: ‘class urdf::Joint’ has no member named ‘dynamics’
     this->dynamics.reset();
           ^
include/urdf_model/joint.h:220:11: error: ‘class urdf::Joint’ has no member named ‘limits’
     this->limits.reset();
           ^
include/urdf_model/joint.h:221:11: error: ‘class urdf::Joint’ has no member named ‘safety’
     this->safety.reset();
           ^
include/urdf_model/joint.h:222:11: error: ‘class urdf::Joint’ has no member named ‘calibration’
     this->calibration.reset();
           ^
include/urdf_model/joint.h:223:11: error: ‘class urdf::Joint’ has no member named ‘mimic’
     this->mimic.reset();
           ^
In file included from include/urdf_model/link.h:45:0,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/color.h: In member function ‘bool urdf::Color::init(const string&)’:
include/urdf_model/color.h:76:26: error: ‘stof’ is not a member of ‘std’
           rgba.push_back(std::stof(pieces[i]));
                          ^
In file included from include/urdf_model/model.h:42:0,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/link.h: At global scope:
include/urdf_model/link.h:152:3: error: ‘GeometrySharedPtr’ does not name a type
   GeometrySharedPtr geometry;
   ^
include/urdf_model/link.h:155:3: error: ‘MaterialSharedPtr’ does not name a type
   MaterialSharedPtr material;
   ^
include/urdf_model/link.h: In member function ‘void urdf::Visual::clear()’:
include/urdf_model/link.h:161:5: error: ‘material’ was not declared in this scope
     material.reset();
     ^
include/urdf_model/link.h:162:5: error: ‘geometry’ was not declared in this scope
     geometry.reset();
     ^
include/urdf_model/link.h: At global scope:
include/urdf_model/link.h:174:3: error: ‘GeometrySharedPtr’ does not name a type
   GeometrySharedPtr geometry;
   ^
include/urdf_model/link.h: In member function ‘void urdf::Collision::clear()’:
include/urdf_model/link.h:179:5: error: ‘geometry’ was not declared in this scope
     geometry.reset();
     ^
include/urdf_model/link.h: At global scope:
include/urdf_model/link.h:196:3: error: ‘InertialSharedPtr’ does not name a type
   InertialSharedPtr inertial;
   ^
include/urdf_model/link.h:199:3: error: ‘VisualSharedPtr’ does not name a type
   VisualSharedPtr visual;
   ^
include/urdf_model/link.h:202:3: error: ‘CollisionSharedPtr’ does not name a type
   CollisionSharedPtr collision;
   ^
In file included from include/urdf_model/model.h:42:0,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/link.h:205:15: error: ‘CollisionSharedPtr’ was not declared in this scope
   std::vector<CollisionSharedPtr> collision_array;
               ^
include/urdf_model/link.h:205:33: error: template argument 1 is invalid
   std::vector<CollisionSharedPtr> collision_array;
                                 ^
include/urdf_model/link.h:205:33: error: template argument 2 is invalid
include/urdf_model/link.h:208:15: error: ‘VisualSharedPtr’ was not declared in this scope
   std::vector<VisualSharedPtr> visual_array;
               ^
include/urdf_model/link.h:208:30: error: template argument 1 is invalid
   std::vector<VisualSharedPtr> visual_array;
                              ^
include/urdf_model/link.h:208:30: error: template argument 2 is invalid
include/urdf_model/link.h:213:3: error: ‘JointSharedPtr’ does not name a type
   JointSharedPtr parent_joint;
   ^
include/urdf_model/link.h:215:15: error: ‘JointSharedPtr’ was not declared in this scope
   std::vector<JointSharedPtr> child_joints;
               ^
include/urdf_model/link.h:215:29: error: template argument 1 is invalid
   std::vector<JointSharedPtr> child_joints;
                             ^
include/urdf_model/link.h:215:29: error: template argument 2 is invalid
include/urdf_model/link.h:216:15: error: ‘LinkSharedPtr’ was not declared in this scope
   std::vector<LinkSharedPtr> child_links;
               ^
include/urdf_model/link.h:216:28: error: template argument 1 is invalid
   std::vector<LinkSharedPtr> child_links;
                            ^
include/urdf_model/link.h:216:28: error: template argument 2 is invalid
include/urdf_model/link.h:218:3: error: ‘LinkSharedPtr’ does not name a type
   LinkSharedPtr getParent() const
   ^
include/urdf_model/link.h:221:24: error: ‘LinkSharedPtr’ does not name a type
   void setParent(const LinkSharedPtr &parent)
                        ^
include/urdf_model/link.h:221:39: error: ISO C++ forbids declaration of ‘parent’ with no type [-fpermissive]
   void setParent(const LinkSharedPtr &parent)
                                       ^
include/urdf_model/link.h:238:3: error: ‘LinkWeakPtr’ does not name a type
   LinkWeakPtr parent_link_;
   ^
include/urdf_model/link.h: In member function ‘void urdf::Link::setParent(const int&)’:
include/urdf_model/link.h:222:5: error: ‘parent_link_’ was not declared in this scope
   { parent_link_ = parent; }
     ^
include/urdf_model/link.h: In member function ‘void urdf::Link::clear()’:
include/urdf_model/link.h:227:11: error: ‘class urdf::Link’ has no member named ‘inertial’
     this->inertial.reset();
           ^
include/urdf_model/link.h:228:11: error: ‘class urdf::Link’ has no member named ‘visual’
     this->visual.reset();
           ^
include/urdf_model/link.h:229:11: error: ‘class urdf::Link’ has no member named ‘collision’
     this->collision.reset();
           ^
include/urdf_model/link.h:230:11: error: ‘class urdf::Link’ has no member named ‘parent_joint’
     this->parent_joint.reset();
           ^
include/urdf_model/link.h:231:24: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::child_joints’, which is of non-class type ‘int’
     this->child_joints.clear();
                        ^
include/urdf_model/link.h:232:23: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::child_links’, which is of non-class type ‘int’
     this->child_links.clear();
                       ^
include/urdf_model/link.h:233:27: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::collision_array’, which is of non-class type ‘int’
     this->collision_array.clear();
                           ^
include/urdf_model/link.h:234:24: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::visual_array’, which is of non-class type ‘int’
     this->visual_array.clear();
                        ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h:51:1: error: expected class-name before ‘{’ token
 {
include/urdf_model/model.h: At global scope:
include/urdf_model/model.h:51:3: error: ‘LinkConstSharedPtr’ does not name a type
   LinkConstSharedPtr getRoot(void) const{return this->root_link_;};
   ^
include/urdf_model/model.h:52:3: error: ‘LinkConstSharedPtr’ does not name a type
   LinkConstSharedPtr getLink(const std::string& name) const
   ^
include/urdf_model/model.h:62:3: error: ‘JointConstSharedPtr’ does not name a type
   JointConstSharedPtr getJoint(const std::string& name) const
   ^
include/urdf_model/model.h:74:29: error: ‘LinkSharedPtr’ was not declared in this scope
   void getLinks(std::vector<LinkSharedPtr >& links) const
                             ^
include/urdf_model/model.h:74:43: error: template argument 1 is invalid
   void getLinks(std::vector<LinkSharedPtr >& links) const
                                           ^
include/urdf_model/model.h:74:43: error: template argument 2 is invalid
include/urdf_model/model.h:92:41: error: ‘LinkSharedPtr’ has not been declared
   void getLink(const std::string& name, LinkSharedPtr &link) const
                                         ^
include/urdf_model/model.h:103:3: error: ‘MaterialSharedPtr’ does not name a type
   MaterialSharedPtr getMaterial(const std::string& name) const
   ^
In file included from test.cpp:11:0:
include/kdl_parser/kdl_parser.hpp:80:30: error: ‘ModelInterface’ in namespace ‘urdf’ include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h:188:25: error: ‘LinkSharedPtr’ was not declared in this scope
   std::map<std::string, LinkSharedPtr> links_;
                         ^
include/urdf_model/model.h:188:38: error: template argument 2 is invalid
   std::map<std::string, LinkSharedPtr> links_;
                                      ^
include/urdf_model/model.h:188:38: error: template argument 4 is invalid
include/urdf_model/model.h:190:25: error: ‘JointSharedPtr’ was not declared in this scope
   std::map<std::string, JointSharedPtr> joints_;
                         ^
include/urdf_model/model.h:190:39: error: template argument 2 is invalid
   std::map<std::string, JointSharedPtr> joints_;
                                       ^
include/urdf_model/model.h:190:39: error: template argument 4 is invalid
include/urdf_model/model.h:192:25: error: ‘MaterialSharedPtr’ was not declared in this scope
   std::map<std::string, MaterialSharedPtr> materials_;
                         ^
include/urdf_model/model.h:192:42: error: template argument 2 is invalid
   std::map<std::string, MaterialSharedPtr> materials_;
                                          ^
include/urdf_model/model.h:192:42: error: template argument 4 is invalid
include/urdf_model/model.h:198:3: error: ‘LinkSharedPtr’ does not name a type
 bool treeFromUrdfModel(const urdf::ModelInterface& robot_model, KDL::Tree& tree);
                              ^
include/kdl_parser/kdl_parser.hpp:80:52:   LinkSharedPtr root_link_;
   ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::getLinks(int&) const’:
include/urdf_model/model.h:76:31: error: ‘LinkSharedPtr’ was not declared in this scope
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                               ^
include/urdf_model/model.h:76:44: error: template argument 2 is invalid
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                            ^
include/urdf_model/model.h:76:44: error: template argument 4 is invalid
include/urdf_model/model.h:76:62: error: invalid type in declaration before ‘link’
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                              ^
include/urdf_model/model.h:76:62: error: expected ‘;’ before ‘link’
include/urdf_model/model.h:76:82: error: request for member ‘begin’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                  ^
include/urdf_model/model.h:76:111: error: request for member ‘end’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                               ^
include/urdf_model/model.h:76:116: error: expected ‘)’ before ‘;’ token
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                                    ^
include/urdf_model/model.h:76:122: error: ISO C++ forbids incrementing a pointer of type ‘int (*)(const char*, const char*)throw ()’ [-fpermissive]
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                                          ^
include/urdf_model/model.h:76:122: error: lvalue required as increment operand
include/urdf_model/model.h:76:124: error: expected ‘;’ before ‘)’ token
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                                            ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::clear()’:
include/urdf_model/model.h:85:18: error: request for member ‘clear’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘int’
     this->links_.clear();
                  ^
include/urdf_model/model.h:86:19: error: request for member ‘clear’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::joints_’, which is of non-class type ‘int’
     this->joints_.clear();
                   ^
include/urdf_model/model.h:87:22: error: request for member ‘clear’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::materials_’, which is of non-class type ‘int’
     this->materials_.clear();
                      ^
include/urdf_model/model.h:88:11: error: ‘class urdf::ModelInterface’ has no member named ‘root_link_’
     this->root_link_.reset();
           ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::getLink(const string&, int&) const’:
include/urdf_model/model.h:94:5: error: ‘LinkSharedPtr’ was not declared in this scope
     LinkSharedPtr ptr;
     ^
include/urdf_model/model.h:94:19: error: expected ‘;’ before ‘ptr’
     LinkSharedPtr ptr;
                   ^
include/urdf_model/model.h:95:22: error: request for member ‘find’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     if (this->links_.find(name) == this->links_.end())
                      ^
include/urdf_model/model.h:95:49: error: request for member ‘end’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     if (this->links_.find(name) == this->links_.end())
                                                 ^
include/urdf_model/model.h:96:7: error: ‘ptr’ was not declared in this scope
       ptr.reset();
       ^
include/urdf_model/model.h:98:7: error: ‘ptr’ was not declared in this scope
       ptr = this->links_.find(name)->second;
       ^
include/urdf_model/model.h:98:26: error: request for member ‘find’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
       ptr = this->links_.find(name)->second;
                          ^
include/urdf_model/model.h:99:12: error: ‘ptr’ was not declared in this scope
     link = ptr;
            ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::initTree(std::map<std::basic_string<char>, std::basic_string<char> >&)’:
include/urdf_model/model.h:116:32: error: ‘JointSharedPtr’ was not declared in this scope
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                ^
include/urdf_model/model.h:116:46: error: template argument 2 is invalid
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                              ^
include/urdf_model/model.h:116:46: error: template argument 4 is invalid
include/urdf_model/model.h:116:58: error: invalid type in declaration before ‘joint’
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                          ^
include/urdf_model/model.h:116:58: error: expected ‘;’ before ‘joint’
include/urdf_model/model.h:116:58: error: ‘joint’ was not declared in this scope
include/urdf_model/model.h:116:80: error: request for member ‘begin’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::joints_’, which is of ‘robot_model’ with non-class type ‘int’
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                ^
include/urdf_model/model.h:116:111: error: request for member ‘end’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::joints_’, which is of non-class type ‘int’
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                               ^
include/urdf_model/model.h:116:116: error: expected ‘)’ before ‘;’ token
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                                    ^
include/urdf_model/model.h:116:118: error: ‘joint’ was not declared in this scope
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                                      ^
include/urdf_model/model.h:116:125: error: expected ‘;’ before ‘)’ token
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                                             ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h:156:3: error: expected ‘}’ at end of input
   }
   ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::initRoot(const std::map<std::basic_string<char>, std::basic_string<char> >&)’:
include/urdf_model/model.h:160:11: error: ‘class urdf::ModelInterface’ has no member named ‘root_link_’
     this->root_link_.reset();
           ^
include/urdf_model/model.h:163:32: error: ‘LinkSharedPtr’ was not declared in this scope
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                ^
include/urdf_model/model.h:163:45: error: template argument 2 is invalid
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                             ^
include/urdf_model/model.h:163:45: error: template argument 4 is invalid
include/urdf_model/model.h:163:63: error: invalid type [-fpermissive]
 bool treeFromUrdfModel(const urdf::ModelInterface& robot_model, KDL::Tree& tree);
                                                    ^
ravi@lab:~/test/calling_ros_lib$
in declaration before ‘l’
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                               ^
include/urdf_model/model.h:163:63: error: expected ‘;’ before ‘l’
include/urdf_model/model.h:163:63: error: ‘l’ was not declared in this scope
include/urdf_model/model.h:163:78: error: request for member ‘begin’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘int’
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                              ^
include/urdf_model/model.h:163:103: error: request for member ‘end’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘int’
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                       ^
include/urdf_model/model.h:163:108: error: expected ‘)’ before ‘;’ token
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                            ^
include/urdf_model/model.h:163:110: error: ‘l’ was not declared in this scope
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                              ^
include/urdf_model/model.h:163:113: error: expected ‘;’ before ‘)’ token
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                                 ^
include/urdf_model/model.h:184:3: error: expected ‘}’ at end of input
   }
   ^
test@test:~/Desktop/calll/calling_so$

How to call these libraries from an external CPP without using ROS?

Calling ROS libraries from external CPP

I want to call the ROS libraries (shared object .so files) from external CPP program. Below are the ROS libraries-

  1. /opt/ros/indigo/lib/libkdl_parser.so
  2. /opt/ros/indigo/lib/liborocos-kdl.so.1.3.0

The main code i.e., test.cpp looks like following-

#include <iostream>
#include <kdl/jntarray.hpp>
#include <kdl/chaindynparam.hpp>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/jntspaceinertiamatrix.hpp>

int main(int argc, char** argv)
{
    std::string urdf_file = "robot.urdf";
    std::string base_link = "base";
    std::string tip_link = "end_effector";

    KDL::Tree tree;
    if (!kdl_parser::treeFromFile(urdf_file, tree)) {
        printf("Failed to construct kdl tree\n");
        return -1;
    }

    KDL::Chain chain;
    if (!tree.getChain(base_link, tip_link, chain))
        printf("Couldn't find chain from %s to %s\n", base_link.c_str(), tip_link.c_str());

    KDL::ChainDynParam dyn(chain, KDL::Vector::Zero());

    KDL::JntArray q(chain.getNrOfJoints()); //dummy value
    KDL::JntSpaceInertiaMatrix H(chain.getNrOfJoints());
    dyn.JntToMass(q, H);

    printf("(0,0) element of Inertia Matrix %f\n", H(0,0));
    return 0;
}

The robot.urdf is kept along with test.cpp and headers are kept in a sub-directory. Below is the directory structure-

test@test:~/Desktop/calll/calling_so$ tree
.
├── robot.urdf
├── errors
├── include
│   ├── kdl
│   │   ├── articulatedbodyinertia.hpp
│   │   ├── chaindynparam.hpp
│   │   ├── chain.hpp
│   │   ├── chainidsolver.hpp
│   │   ├── chainidsolver_recursive_newton_euler.hpp
│   │   ├── config.h
│   │   ├── frames.hpp
│   │   ├── frames.inl
│   │   ├── jacobian.hpp
│   │   ├── jntarray.hpp
│   │   ├── jntspaceinertiamatrix.hpp
│   │   ├── joint.hpp
│   │   ├── rigidbodyinertia.hpp
│   │   ├── rotationalinertia.hpp
│   │   ├── segment.hpp
│   │   ├── tree.hpp
│   │   └── utilities
│   │       ├── kdl-config.h
│   │       └── utility.h
│   ├── kdl_parser
│   │   └── kdl_parser.hpp
│   ├── urdf
│   │   ├── model.h
│   │   └── urdfdom_compatibility.h
│   ├── urdf_exception
│   │   └── exception.h
│   └── urdf_model
│       ├── color.h
│       ├── joint.h
│       ├── link.h
│       ├── model.h
│       ├── pose.h
│       ├── types.h
│       └── utils.h
├── shared
│   ├── libkdl_parser.so
│   ├── liborocos-kdl.so -> liborocos-kdl.so.1.4
│   ├── liborocos-kdl.so.1.4 liborocos-kdl.so.1.3
│   ├── liborocos-kdl.so.1.3 -> liborocos-kdl.so.1.4.0
│   └── liborocos-kdl.so.1.4.0
liborocos-kdl.so.1.3.0
│   └── liborocos-kdl.so.1.3.0
└── test.cpp

8 directories, 36 files

I used gcc to compile the test.cpp with following command-

gcc -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl.so -lkdl_parser.so -std=c++11 test.cpp -Iinclude/ -I/usr/include/eigen3/ -Lshared/ -lkdl_parser.so -lorocos-kdl.so -o test

but it is not working, since there are few more dependecies linker is not able to satisfy. find out shared object files. Below is the complete error trace--

test@test:~/Desktop/calll/calling_so$  gcc -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl.so -lkdl_parser.so -std=c++11 test.cpp -Iinclude/ -I/usr/include/eigen3/ -Lshared/ -lkdl_parser.so -lorocos-kdl.so -o test
In file included from include/urdf_model/joint.h:43:0,
                 from include/urdf_model/link.h:44,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/pose.h: In member function ‘void urdf::Vector3::init(const string&)’:
include/urdf_model/pose.h:78:25: /usr/bin/ld: cannot find -lorocos-kdl.so
/usr/bin/ld: cannot find -lkdl_parser.so
collect2: error: ‘stod’ is not a member of ‘std’
           xyz.push_back(std::stod(pieces[i]));
                         ^
In file included from include/urdf_model/joint.h:43:0,
                 from include/urdf_model/link.h:44,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/pose.h:90:42: error: ‘to_string’ is not a member of ‘std’
       throw ParseError("Parser found " + std::to_string(xyz.size())  + " elements but 3 expected while parsing vector [" + vector_str + "]");
                                          ^
In file included from include/urdf_model/joint.h:44:0,
                 from include/urdf_model/link.h:44,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/types.h: At global scope:
include/urdf_model/types.h:51:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<double> DoubleSharedPtr;
         ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:53:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Box);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:53:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Box);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:53:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Box);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:54:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Collision);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:54:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Collision);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:54:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Collision);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:55:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Cylinder);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:55:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Cylinder);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:55:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Cylinder);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:56:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Geometry);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:56:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Geometry);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:56:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Geometry);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:57:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Inertial);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:57:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Inertial);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:57:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Inertial);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:58:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Joint);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:58:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Joint);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:58:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Joint);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:59:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointCalibration);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:59:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointCalibration);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:59:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointCalibration);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:60:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointDynamics);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:60:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointDynamics);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:60:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointDynamics);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:61:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointLimits);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:61:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointLimits);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:61:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointLimits);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:62:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointMimic);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:62:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointMimic);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:62:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointMimic);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:63:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointSafety);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:63:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointSafety);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:63:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(JointSafety);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:64:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Link);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:64:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Link);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:64:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Link);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:65:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Material);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:65:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Material);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:65:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Material);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:66:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Mesh);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:66:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Mesh);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:66:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Mesh);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:67:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Sphere);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:67:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Sphere);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:67:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Sphere);
 ^
include/urdf_model/types.h:44:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<Class> Class##SharedPtr; \
         ^
include/urdf_model/types.h:68:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Visual);
 ^
include/urdf_model/types.h:45:9: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 typedef std::shared_ptr<const Class> Class##ConstSharedPtr; \
         ^
include/urdf_model/types.h:68:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Visual);
 ^
include/urdf_model/types.h:46:9: error: ‘weak_ptr’ in namespace ‘std’ does not name a type
 typedef std::weak_ptr<Class> Class##WeakPtr
         ^
include/urdf_model/types.h:68:1: note: in expansion of macro ‘URDF_TYPEDEF_CLASS_POINTER’
 URDF_TYPEDEF_CLASS_POINTER(Visual);
 ^
include/urdf_model/types.h:72:1: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 std::shared_ptr<T> const_pointer_cast(std::shared_ptr<U> const & r)
 ^
include/urdf_model/types.h:78:1: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 std::shared_ptr<T> dynamic_pointer_cast(std::shared_ptr<U> const & r)
 ^
include/urdf_model/types.h:84:1: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
 std::shared_ptr<T> static_pointer_cast(std::shared_ptr<U> const & r)
 ^
In file included from include/urdf_model/link.h:44:0,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/joint.h:141:3: error: ‘DoubleSharedPtr’ does not name a type
   DoubleSharedPtr rising, falling;
   ^
include/urdf_model/joint.h:199:3: error: ‘JointDynamicsSharedPtr’ does not name a type
   JointDynamicsSharedPtr dynamics;
   ^
include/urdf_model/joint.h:202:3: error: ‘JointLimitsSharedPtr’ does not name a type
   JointLimitsSharedPtr limits;
   ^
include/urdf_model/joint.h:205:3: error: ‘JointSafetySharedPtr’ does not name a type
   JointSafetySharedPtr safety;
   ^
include/urdf_model/joint.h:208:3: error: ‘JointCalibrationSharedPtr’ does not name a type
   JointCalibrationSharedPtr calibration;
   ^
include/urdf_model/joint.h:211:3: error: ‘JointMimicSharedPtr’ does not name a type
   JointMimicSharedPtr mimic;
   ^
include/urdf_model/joint.h: In member function ‘void urdf::Joint::clear()’:
include/urdf_model/joint.h:219:11: error: ‘class urdf::Joint’ has no member named ‘dynamics’
     this->dynamics.reset();
           ^
include/urdf_model/joint.h:220:11: error: ‘class urdf::Joint’ has no member named ‘limits’
     this->limits.reset();
           ^
include/urdf_model/joint.h:221:11: error: ‘class urdf::Joint’ has no member named ‘safety’
     this->safety.reset();
           ^
include/urdf_model/joint.h:222:11: error: ‘class urdf::Joint’ has no member named ‘calibration’
     this->calibration.reset();
           ^
include/urdf_model/joint.h:223:11: error: ‘class urdf::Joint’ has no member named ‘mimic’
     this->mimic.reset();
           ^
In file included from include/urdf_model/link.h:45:0,
                 from include/urdf_model/model.h:42,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/color.h: In member function ‘bool urdf::Color::init(const string&)’:
include/urdf_model/color.h:76:26: error: ‘stof’ is not a member of ‘std’
           rgba.push_back(std::stof(pieces[i]));
                          ^
In file included from include/urdf_model/model.h:42:0,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/link.h: At global scope:
include/urdf_model/link.h:152:3: error: ‘GeometrySharedPtr’ does not name a type
   GeometrySharedPtr geometry;
   ^
include/urdf_model/link.h:155:3: error: ‘MaterialSharedPtr’ does not name a type
   MaterialSharedPtr material;
   ^
include/urdf_model/link.h: In member function ‘void urdf::Visual::clear()’:
include/urdf_model/link.h:161:5: error: ‘material’ was not declared in this scope
     material.reset();
     ^
include/urdf_model/link.h:162:5: error: ‘geometry’ was not declared in this scope
     geometry.reset();
     ^
include/urdf_model/link.h: At global scope:
include/urdf_model/link.h:174:3: error: ‘GeometrySharedPtr’ does not name a type
   GeometrySharedPtr geometry;
   ^
include/urdf_model/link.h: In member function ‘void urdf::Collision::clear()’:
include/urdf_model/link.h:179:5: error: ‘geometry’ was not declared in this scope
     geometry.reset();
     ^
include/urdf_model/link.h: At global scope:
include/urdf_model/link.h:196:3: error: ‘InertialSharedPtr’ does not name a type
   InertialSharedPtr inertial;
   ^
include/urdf_model/link.h:199:3: error: ‘VisualSharedPtr’ does not name a type
   VisualSharedPtr visual;
   ^
include/urdf_model/link.h:202:3: error: ‘CollisionSharedPtr’ does not name a type
   CollisionSharedPtr collision;
   ^
In file included from include/urdf_model/model.h:42:0,
                 from include/kdl_parser/kdl_parser.hpp:42,
                 from test.cpp:11:
include/urdf_model/link.h:205:15: error: ‘CollisionSharedPtr’ was not declared in this scope
   std::vector<CollisionSharedPtr> collision_array;
               ^
include/urdf_model/link.h:205:33: error: template argument ld returned 1 is invalid
   std::vector<CollisionSharedPtr> collision_array;
                                 ^
include/urdf_model/link.h:205:33: error: template argument exit status
test@test:~/Desktop/calll/calling_so$ ll shared/
total 544
drwxrwx--- 2 is invalid
include/urdf_model/link.h:208:15: error: ‘VisualSharedPtr’ was not declared in this scope
   std::vector<VisualSharedPtr> visual_array;
               ^
include/urdf_model/link.h:208:30: error: template argument test test   4096 Nov 13 23:39 ./
drwxrwx--- 4 test test   4096 Nov 13 23:47 ../
-rwxrwx--- 1 is invalid
   std::vector<VisualSharedPtr> visual_array;
                              ^
include/urdf_model/link.h:208:30: error: template argument 2 is invalid
include/urdf_model/link.h:213:3: error: ‘JointSharedPtr’ does not name a type
   JointSharedPtr parent_joint;
   ^
include/urdf_model/link.h:215:15: error: ‘JointSharedPtr’ was not declared in this scope
   std::vector<JointSharedPtr> child_joints;
               ^
include/urdf_model/link.h:215:29: error: template argument test test  27104 Jun 29 00:21 libkdl_parser.so*
lrwxrwxrwx 1 is invalid
   std::vector<JointSharedPtr> child_joints;
                             ^
include/urdf_model/link.h:215:29: error: template argument 2 is invalid
include/urdf_model/link.h:216:15: error: ‘LinkSharedPtr’ was not declared in this scope
   std::vector<LinkSharedPtr> child_links;
               ^
include/urdf_model/link.h:216:28: error: template argument test test     20 Nov 13 23:39 liborocos-kdl.so -> liborocos-kdl.so.1.3*
lrwxrwxrwx 1 is invalid
   std::vector<LinkSharedPtr> child_links;
                            ^
include/urdf_model/link.h:216:28: error: template argument 2 is invalid
include/urdf_model/link.h:218:3: error: ‘LinkSharedPtr’ does not name a type
   LinkSharedPtr getParent() const
   ^
include/urdf_model/link.h:221:24: error: ‘LinkSharedPtr’ does not name a type
   void setParent(const LinkSharedPtr &parent)
                        ^
include/urdf_model/link.h:221:39: error: ISO C++ forbids declaration of ‘parent’ with no type [-fpermissive]
   void setParent(const LinkSharedPtr &parent)
                                       ^
include/urdf_model/link.h:238:3: error: ‘LinkWeakPtr’ does not name a type
   LinkWeakPtr parent_link_;
   ^
include/urdf_model/link.h: In member function ‘void urdf::Link::setParent(const int&)’:
include/urdf_model/link.h:222:5: error: ‘parent_link_’ was not declared in this scope
   { parent_link_ = parent; }
     ^
include/urdf_model/link.h: In member function ‘void urdf::Link::clear()’:
include/urdf_model/link.h:227:11: error: ‘class urdf::Link’ has no member named ‘inertial’
     this->inertial.reset();
           ^
include/urdf_model/link.h:228:11: error: ‘class urdf::Link’ has no member named ‘visual’
     this->visual.reset();
           ^
include/urdf_model/link.h:229:11: error: ‘class urdf::Link’ has no member named ‘collision’
     this->collision.reset();
           ^
include/urdf_model/link.h:230:11: error: ‘class urdf::Link’ has no member named ‘parent_joint’
     this->parent_joint.reset();
           ^
include/urdf_model/link.h:231:24: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::child_joints’, which is of non-class type ‘int’
     this->child_joints.clear();
                        ^
include/urdf_model/link.h:232:23: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::child_links’, which is of non-class type ‘int’
     this->child_links.clear();
                       ^
include/urdf_model/link.h:233:27: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::collision_array’, which is of non-class type ‘int’
     this->collision_array.clear();
                           ^
include/urdf_model/link.h:234:24: error: request for member ‘clear’ in ‘((urdf::Link*)this)->urdf::Link::visual_array’, which is of non-class type ‘int’
     this->visual_array.clear();
                        ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h: At global scope:
include/urdf_model/model.h:51:3: error: ‘LinkConstSharedPtr’ does not name a type
   LinkConstSharedPtr getRoot(void) const{return this->root_link_;};
   ^
include/urdf_model/model.h:52:3: error: ‘LinkConstSharedPtr’ does not name a type
   LinkConstSharedPtr getLink(const std::string& name) const
   ^
include/urdf_model/model.h:62:3: error: ‘JointConstSharedPtr’ does not name a type
   JointConstSharedPtr getJoint(const std::string& name) const
   ^
include/urdf_model/model.h:74:29: error: ‘LinkSharedPtr’ was not declared in this scope
   void getLinks(std::vector<LinkSharedPtr >& links) const
                             ^
include/urdf_model/model.h:74:43: error: template argument test test     22 Nov 13 23:39 liborocos-kdl.so.1.3 -> liborocos-kdl.so.1.3.0*
-rwxrwx--- 1 is invalid
   void getLinks(std::vector<LinkSharedPtr >& links) const
                                           ^
include/urdf_model/model.h:74:43: error: template argument 2 is invalid
include/urdf_model/model.h:92:41: error: ‘LinkSharedPtr’ has not been declared
   void getLink(const std::string& name, LinkSharedPtr &link) const
                                         ^
include/urdf_model/model.h:103:3: error: ‘MaterialSharedPtr’ does not name a type
   MaterialSharedPtr getMaterial(const std::string& name) const
   ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h:188:25: error: ‘LinkSharedPtr’ was not declared in this scope
   std::map<std::string, LinkSharedPtr> links_;
                         ^
include/urdf_model/model.h:188:38: error: template argument 2 is invalid
   std::map<std::string, LinkSharedPtr> links_;
                                      ^
include/urdf_model/model.h:188:38: error: template argument 4 is invalid
include/urdf_model/model.h:190:25: error: ‘JointSharedPtr’ was not declared in this scope
   std::map<std::string, JointSharedPtr> joints_;
                         ^
include/urdf_model/model.h:190:39: error: template argument 2 is invalid
   std::map<std::string, JointSharedPtr> joints_;
                                       ^
include/urdf_model/model.h:190:39: error: template argument 4 is invalid
include/urdf_model/model.h:192:25: error: ‘MaterialSharedPtr’ was not declared in this scope
   std::map<std::string, MaterialSharedPtr> materials_;
                         ^
include/urdf_model/model.h:192:42: error: template argument 2 is invalid
   std::map<std::string, MaterialSharedPtr> materials_;
                                          ^
include/urdf_model/model.h:192:42: error: template argument 4 is invalid
include/urdf_model/model.h:198:3: error: ‘LinkSharedPtr’ does not name a type
   LinkSharedPtr root_link_;
   ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::getLinks(int&) const’:
include/urdf_model/model.h:76:31: error: ‘LinkSharedPtr’ was not declared in this scope
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                               ^
include/urdf_model/model.h:76:44: error: template argument 2 is invalid
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                            ^
include/urdf_model/model.h:76:44: error: template argument 4 is invalid
include/urdf_model/model.h:76:62: error: invalid type in declaration before ‘link’
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                              ^
include/urdf_model/model.h:76:62: error: expected ‘;’ before ‘link’
include/urdf_model/model.h:76:82: error: request for member ‘begin’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                  ^
include/urdf_model/model.h:76:111: error: request for member ‘end’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                               ^
include/urdf_model/model.h:76:116: error: expected ‘)’ before ‘;’ token
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                                    ^
include/urdf_model/model.h:76:122: error: ISO C++ forbids incrementing a pointer of type ‘int (*)(const char*, const char*)throw ()’ [-fpermissive]
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                                          ^
include/urdf_model/model.h:76:122: error: lvalue required as increment operand
include/urdf_model/model.h:76:124: error: expected ‘;’ before ‘)’ token
     for (std::map<std::string,LinkSharedPtr>::const_iterator link = this->links_.begin();link != this->links_.end(); link++)
                                                                                                                            ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::clear()’:
include/urdf_model/model.h:85:18: error: request for member ‘clear’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘int’
     this->links_.clear();
                  ^
include/urdf_model/model.h:86:19: error: request for member ‘clear’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::joints_’, which is of non-class type ‘int’
     this->joints_.clear();
                   ^
include/urdf_model/model.h:87:22: error: request for member ‘clear’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::materials_’, which is of non-class type ‘int’
     this->materials_.clear();
                      ^
include/urdf_model/model.h:88:11: error: ‘class urdf::ModelInterface’ has no member named ‘root_link_’
     this->root_link_.reset();
           ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::getLink(const string&, int&) const’:
include/urdf_model/model.h:94:5: error: ‘LinkSharedPtr’ was not declared in this scope
     LinkSharedPtr ptr;
     ^
include/urdf_model/model.h:94:19: error: expected ‘;’ before ‘ptr’
     LinkSharedPtr ptr;
                   ^
include/urdf_model/model.h:95:22: error: request for member ‘find’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     if (this->links_.find(name) == this->links_.end())
                      ^
include/urdf_model/model.h:95:49: error: request for member ‘end’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
     if (this->links_.find(name) == this->links_.end())
                                                 ^
include/urdf_model/model.h:96:7: error: ‘ptr’ was not declared in this scope
       ptr.reset();
       ^
include/urdf_model/model.h:98:7: error: ‘ptr’ was not declared in this scope
       ptr = this->links_.find(name)->second;
       ^
include/urdf_model/model.h:98:26: error: request for member ‘find’ in ‘((const urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘const int’
       ptr = this->links_.find(name)->second;
                          ^
include/urdf_model/model.h:99:12: error: ‘ptr’ was not declared in this scope
     link = ptr;
            ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::initTree(std::map<std::basic_string<char>, std::basic_string<char> >&)’:
include/urdf_model/model.h:116:32: error: ‘JointSharedPtr’ was not declared in this scope
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                ^
include/urdf_model/model.h:116:46: error: template argument 2 is invalid
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                              ^
include/urdf_model/model.h:116:46: error: template argument 4 is invalid
include/urdf_model/model.h:116:58: error: invalid type in declaration before ‘joint’
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                          ^
include/urdf_model/model.h:116:58: error: expected ‘;’ before ‘joint’
include/urdf_model/model.h:116:58: error: ‘joint’ was not declared in this scope
include/urdf_model/model.h:116:80: error: request for member ‘begin’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::joints_’, which is of non-class type ‘int’
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                ^
include/urdf_model/model.h:116:111: error: request for member ‘end’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::joints_’, which is of non-class type ‘int’
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                               ^
include/urdf_model/model.h:116:116: error: expected ‘)’ before ‘;’ token
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                                    ^
include/urdf_model/model.h:116:118: error: ‘joint’ was not declared in this scope
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                                      ^
include/urdf_model/model.h:116:125: error: expected ‘;’ before ‘)’ token
     for (std::map<std::string, JointSharedPtr>::iterator joint = this->joints_.begin();joint != this->joints_.end(); joint++)
                                                                                                                             ^
In file included from include/kdl_parser/kdl_parser.hpp:42:0,
                 from test.cpp:11:
include/urdf_model/model.h:156:3: error: expected ‘}’ at end of input
   }
   ^
include/urdf_model/model.h: In member function ‘void urdf::ModelInterface::initRoot(const std::map<std::basic_string<char>, std::basic_string<char> >&)’:
include/urdf_model/model.h:160:11: error: ‘class urdf::ModelInterface’ has no member named ‘root_link_’
     this->root_link_.reset();
           ^
include/urdf_model/model.h:163:32: error: ‘LinkSharedPtr’ was not declared in this scope
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                ^
include/urdf_model/model.h:163:45: error: template argument 2 is invalid
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                             ^
include/urdf_model/model.h:163:45: error: template argument 4 is invalid
include/urdf_model/model.h:163:63: error: invalid type in declaration before ‘l’
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                               ^
include/urdf_model/model.h:163:63: error: expected ‘;’ before ‘l’
include/urdf_model/model.h:163:63: error: ‘l’ was not declared in this scope
include/urdf_model/model.h:163:78: error: request for member ‘begin’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘int’
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                              ^
include/urdf_model/model.h:163:103: error: request for member ‘end’ in ‘((urdf::ModelInterface*)this)->urdf::ModelInterface::links_’, which is of non-class type ‘int’
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                       ^
include/urdf_model/model.h:163:108: error: expected ‘)’ before ‘;’ token
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                            ^
include/urdf_model/model.h:163:110: error: ‘l’ was not declared in this scope
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                              ^
include/urdf_model/model.h:163:113: error: expected ‘;’ before ‘)’ token
     for (std::map<std::string, LinkSharedPtr>::const_iterator l=this->links_.begin(); l!=this->links_.end(); l++)
                                                                                                                 ^
include/urdf_model/model.h:184:3: error: expected ‘}’ at end of input
   }
   ^
test test 516760 Apr  6  2016 liborocos-kdl.so.1.3.0*
test@test:~/Desktop/calll/calling_so$

How to call these libraries from an external CPP without using ROS?

Calling ROS libraries from external CPP

I want to call the ROS libraries (shared object .so files) from external CPP program. Below are the ROS libraries-

  1. /opt/ros/indigo/lib/libkdl_parser.so
  2. /opt/ros/indigo/lib/liborocos-kdl.so.1.3.0

The main code i.e., test.cpp looks like following-

#include <iostream>
#include <kdl/jntarray.hpp>
#include <kdl/chaindynparam.hpp>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/jntspaceinertiamatrix.hpp>

int main(int argc, char** argv)
{
    std::string urdf_file = "robot.urdf";
    std::string base_link = "base";
    std::string tip_link = "end_effector";

    KDL::Tree tree;
    if (!kdl_parser::treeFromFile(urdf_file, tree)) {
        printf("Failed to construct kdl tree\n");
        return -1;
    }

    KDL::Chain chain;
    if (!tree.getChain(base_link, tip_link, chain))
        printf("Couldn't find chain from %s to %s\n", base_link.c_str(), tip_link.c_str());

    KDL::ChainDynParam dyn(chain, KDL::Vector::Zero());

    KDL::JntArray q(chain.getNrOfJoints()); //dummy value
    KDL::JntSpaceInertiaMatrix H(chain.getNrOfJoints());
    dyn.JntToMass(q, H);

    printf("(0,0) element of Inertia Matrix %f\n", H(0,0));
    return 0;
}

The robot.urdf is kept along with test.cpp and headers are kept in a sub-directory. Below is the directory structure-

test@test:~/Desktop/calll/calling_so$ tree
.
├── robot.urdf
├── errors
├── include
│   ├── kdl
│   │   ├── articulatedbodyinertia.hpp
│   │   ├── chaindynparam.hpp
│   │   ├── chain.hpp
│   │   ├── chainidsolver.hpp
│   │   ├── chainidsolver_recursive_newton_euler.hpp
│   │   ├── config.h
│   │   ├── frames.hpp
│   │   ├── frames.inl
│   │   ├── jacobian.hpp
│   │   ├── jntarray.hpp
│   │   ├── jntspaceinertiamatrix.hpp
│   │   ├── joint.hpp
│   │   ├── rigidbodyinertia.hpp
│   │   ├── rotationalinertia.hpp
│   │   ├── segment.hpp
│   │   ├── tree.hpp
│   │   └── utilities
│   │       ├── kdl-config.h
│   │       └── utility.h
│   ├── kdl_parser
│   │   └── kdl_parser.hpp
│   ├── urdf
│   │   ├── model.h
│   │   └── urdfdom_compatibility.h
│   ├── urdf_exception
│   │   └── exception.h
│   └── urdf_model
│       ├── color.h
│       ├── joint.h
│       ├── link.h
│       ├── model.h
│       ├── pose.h
│       ├── types.h
│       └── utils.h
├── shared
│   ├── libkdl_parser.so
│   ├── liborocos-kdl.so -> liborocos-kdl.so.1.3
│   ├── liborocos-kdl.so.1.3 -> liborocos-kdl.so.1.3.0
│   └── liborocos-kdl.so.1.3.0
└── test.cpp

8 directories, 36 files

I used gcc to compile the test.cpp with following command-

gcc -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl.so -lkdl_parser.so -lorocos-kdl -lkdl_parser -std=c++11 test.cpp -o test

but it is not working, since linker is not able to find out shared object files. few more dependencies need to satisfy. Below is the error -

test@test:~/Desktop/calll/calling_so$ gcc -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl.so -lkdl_parser.so -lorocos-kdl -lkdl_parser -std=c++11 test.cpp -o test
/usr/bin/ld: cannot find -lorocos-kdl.so
/usr/bin/ld: cannot find -lkdl_parser.so
/tmp/cc0jWcv9.o: In function `main':
test.cpp:(.text+0x24): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x3f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0x4e): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x5d): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x78): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0x87): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x96): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0xb1): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0xc0): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0xcf): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0xea): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0x103): undefined reference to `KDL::Tree::Tree(std::string const&)'
test.cpp:(.text+0x112): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x121): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x13a): undefined reference to `kdl_parser::treeFromFile(std::string const&, KDL::Tree&)'
test.cpp:(.text+0x164): undefined reference to `KDL::Chain::Chain()'
test.cpp:(.text+0x188): undefined reference to `KDL::Tree::getChain(std::string const&, std::string const&, KDL::Chain&) const'
test.cpp:(.text+0x19e): undefined reference to `std::string::c_str() const'
test.cpp:(.text+0x1b0): undefined reference to `std::string::c_str() const'
test.cpp:(.text+0x1f4): undefined reference to `KDL::ChainDynParam::ChainDynParam(KDL::Chain const&, KDL::Vector)'
test.cpp:(.text+0x216): undefined reference to `KDL::JntArray::JntArray(unsigned int)'
test.cpp:(.text+0x238): undefined reference to `KDL::JntSpaceInertiaMatrix::JntSpaceInertiaMatrix(int)'
test.cpp:(.text+0x258): undefined reference to `KDL::ChainDynParam::JntToMass(KDL::JntArray const&, KDL::JntSpaceInertiaMatrix&)'
test.cpp:(.text+0x271): undefined reference to `KDL::JntSpaceInertiaMatrix::operator()(unsigned int, unsigned int)'
test.cpp:(.text+0x2a6): undefined reference to `KDL::JntSpaceInertiaMatrix::~JntSpaceInertiaMatrix()'
test.cpp:(.text+0x2b5): undefined reference to `KDL::JntArray::~JntArray()'
test.cpp:(.text+0x2c4): undefined reference to `KDL::ChainDynParam::~ChainDynParam()'
test.cpp:(.text+0x2d3): undefined reference to `KDL::Chain::~Chain()'
test.cpp:(.text+0x2f1): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x300): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x30f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x328): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x345): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x35c): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x373): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x387): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x39b): undefined reference to `KDL::JntSpaceInertiaMatrix::~JntSpaceInertiaMatrix()'
test.cpp:(.text+0x3af): undefined reference to `KDL::JntArray::~JntArray()'
test.cpp:(.text+0x3c3): undefined reference to `KDL::ChainDynParam::~ChainDynParam()'
test.cpp:(.text+0x3d7): undefined reference to `KDL::Chain::~Chain()'
test.cpp:(.text+0x3fa): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x409): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x418): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cc0jWcv9.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x454): undefined reference to `std::ios_base::Init::Init()'
test.cpp:(.text+0x463): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc0jWcv9.o: In function `KDL::TreeElement::~TreeElement()':
test.cpp:(.text._ZN3KDL11TreeElementD2Ev[_ZN3KDL11TreeElementD5Ev]+0x26): undefined reference to `KDL::Segment::~Segment()'
/tmp/cc0jWcv9.o: In function `KDL::Tree::~Tree()':
test.cpp:(.text._ZN3KDL4TreeD2Ev[_ZN3KDL4TreeD5Ev]+0x23): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text._ZN3KDL4TreeD2Ev[_ZN3KDL4TreeD5Ev]+0x48): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o: In function `KDL::Tree::~Tree()':
test.cpp:(.text._ZN3KDL4TreeD0Ev[_ZN3KDL4TreeD0Ev]+0x20): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o: In function `__gnu_cxx::new_allocator<std::_Rb_tree_const_iterator<std::pair<std::string const, KDL::TreeElement> > >::deallocate(std::_Rb_tree_const_iterator<std::pair<std::string const, KDL::TreeElement> >*, unsigned long)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt23_Rb_tree_const_iteratorISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m[_ZN9__gnu_cxx13new_allocatorISt23_Rb_tree_const_iteratorISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m]+0x1c): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o: In function `std::pair<std::string const, KDL::TreeElement>::~pair()':
test.cpp:(.text._ZNSt4pairIKSsN3KDL11TreeElementEED2Ev[_ZNSt4pairIKSsN3KDL11TreeElementEED5Ev]+0x24): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cc0jWcv9.o: In function `__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, KDL::TreeElement> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, KDL::TreeElement> >*, unsigned long)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m]+0x1c): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o:(.rodata._ZTIN3KDL4TreeE[_ZTIN3KDL4TreeE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/tmp/cc0jWcv9.o:(.eh_frame+0x10b): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
test@test:~/Desktop/calll/calling_so$ ll shared/
total 544
drwxrwx--- 2 test test   4096 Nov 13 23:39 ./
drwxrwx--- 4 test test   4096 Nov 13 23:47 ../
-rwxrwx--- 1 test test  27104 Jun 29 00:21 libkdl_parser.so*
lrwxrwxrwx 1 test test     20 Nov 13 23:39 liborocos-kdl.so -> liborocos-kdl.so.1.3*
lrwxrwxrwx 1 test test     22 Nov 13 23:39 liborocos-kdl.so.1.3 -> liborocos-kdl.so.1.3.0*
-rwxrwx--- 1 test test 516760 Apr  6  2016 liborocos-kdl.so.1.3.0*
test@test:~/Desktop/calll/calling_so$

How to call these libraries from an external CPP without using ROS?

Calling ROS libraries from external CPP

I want to call the ROS libraries (shared object .so files) from external CPP program. Below are the ROS libraries-

  1. /opt/ros/indigo/lib/libkdl_parser.so
  2. /opt/ros/indigo/lib/liborocos-kdl.so.1.3.0

The main code i.e., test.cpp looks like following-

#include <iostream>
#include <kdl/jntarray.hpp>
#include <kdl/chaindynparam.hpp>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/jntspaceinertiamatrix.hpp>

int main(int argc, char** argv)
{
    std::string urdf_file = "robot.urdf";
    std::string base_link = "base";
    std::string tip_link = "end_effector";

    KDL::Tree tree;
    if (!kdl_parser::treeFromFile(urdf_file, tree)) {
        printf("Failed to construct kdl tree\n");
        return -1;
    }

    KDL::Chain chain;
    if (!tree.getChain(base_link, tip_link, chain))
        printf("Couldn't find chain from %s to %s\n", base_link.c_str(), tip_link.c_str());

    KDL::ChainDynParam dyn(chain, KDL::Vector::Zero());

    KDL::JntArray q(chain.getNrOfJoints()); //dummy value
    KDL::JntSpaceInertiaMatrix H(chain.getNrOfJoints());
    dyn.JntToMass(q, H);

    printf("(0,0) element of Inertia Matrix %f\n", H(0,0));
    return 0;
}

The robot.urdf is kept along with test.cpp and headers are kept in a sub-directory. Below is the directory structure-

test@test:~/Desktop/calll/calling_so$ tree
.
├── robot.urdf
├── errors
├── include
│   ├── kdl
│   │   ├── articulatedbodyinertia.hpp
│   │   ├── chaindynparam.hpp
│   │   ├── chain.hpp
│   │   ├── chainidsolver.hpp
│   │   ├── chainidsolver_recursive_newton_euler.hpp
│   │   ├── config.h
│   │   ├── frames.hpp
│   │   ├── frames.inl
│   │   ├── jacobian.hpp
│   │   ├── jntarray.hpp
│   │   ├── jntspaceinertiamatrix.hpp
│   │   ├── joint.hpp
│   │   ├── rigidbodyinertia.hpp
│   │   ├── rotationalinertia.hpp
│   │   ├── segment.hpp
│   │   ├── tree.hpp
│   │   └── utilities
│   │       ├── kdl-config.h
│   │       └── utility.h
│   ├── kdl_parser
│   │   └── kdl_parser.hpp
│   ├── urdf
│   │   ├── model.h
│   │   └── urdfdom_compatibility.h
│   ├── urdf_exception
│   │   └── exception.h
│   └── urdf_model
│       ├── color.h
│       ├── joint.h
│       ├── link.h
│       ├── model.h
│       ├── pose.h
│       ├── types.h
│       └── utils.h
├── shared
│   ├── libkdl_parser.so
│   ├── liborocos-kdl.so -> liborocos-kdl.so.1.3
│   ├── liborocos-kdl.so.1.3 -> liborocos-kdl.so.1.3.0
│   └── liborocos-kdl.so.1.3.0
└── test.cpp

8 directories, 36 files

I used gcc to compile the test.cpp with following command-

gcc g++ -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl -lkdl_parser -std=c++11 test.cpp -o test

but it is not working, since few more dependencies need to satisfy. Below is the error -

test@test:~/Desktop/calll/calling_so$ gcc g++ -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl -lkdl_parser -std=c++11 test.cpp -o test
/tmp/cc0jWcv9.o: /tmp/ccVP6thR.o: In function `main':
test.cpp:(.text+0x24): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x3f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0x4e): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x5d): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x78): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0x87): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x96): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0xb1): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0xc0): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0xcf): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0xea): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
test.cpp:(.text+0x103): undefined reference to `KDL::Tree::Tree(std::string const&)'
test.cpp:(.text+0x112): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x121): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x13a): undefined reference to `kdl_parser::treeFromFile(std::string const&, KDL::Tree&)'
test.cpp:(.text+0x164): undefined reference to `KDL::Chain::Chain()'
test.cpp:(.text+0x188): undefined reference to `KDL::Tree::getChain(std::string const&, std::string const&, KDL::Chain&) const'
test.cpp:(.text+0x19e): undefined reference to `std::string::c_str() const'
test.cpp:(.text+0x1b0): undefined reference to `std::string::c_str() const'
test.cpp:(.text+0x1f4): undefined reference to `KDL::ChainDynParam::ChainDynParam(KDL::Chain const&, KDL::Vector)'
test.cpp:(.text+0x216): undefined reference to `KDL::JntArray::JntArray(unsigned int)'
test.cpp:(.text+0x238): undefined reference to `KDL::JntSpaceInertiaMatrix::JntSpaceInertiaMatrix(int)'
test.cpp:(.text+0x258): undefined reference to `KDL::ChainDynParam::JntToMass(KDL::JntArray const&, KDL::JntSpaceInertiaMatrix&)'
test.cpp:(.text+0x271): undefined reference to `KDL::JntSpaceInertiaMatrix::operator()(unsigned int, unsigned int)'
test.cpp:(.text+0x2a6): undefined reference to `KDL::JntSpaceInertiaMatrix::~JntSpaceInertiaMatrix()'
test.cpp:(.text+0x2b5): undefined reference to `KDL::JntArray::~JntArray()'
test.cpp:(.text+0x2c4): undefined reference to `KDL::ChainDynParam::~ChainDynParam()'
test.cpp:(.text+0x2d3): undefined reference to `KDL::Chain::~Chain()'
test.cpp:(.text+0x2f1): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x300): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x30f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x328): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x345): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x35c): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x373): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x387): undefined reference to `std::allocator<char>::~allocator()'
test.cpp:(.text+0x39b): undefined reference to `KDL::JntSpaceInertiaMatrix::~JntSpaceInertiaMatrix()'
test.cpp:(.text+0x3af): undefined reference to `KDL::JntArray::~JntArray()'
test.cpp:(.text+0x3c3): undefined reference to `KDL::ChainDynParam::~ChainDynParam()'
test.cpp:(.text+0x3d7): undefined reference to `KDL::Chain::~Chain()'
test.cpp:(.text+0x3fa): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x409): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text+0x418): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cc0jWcv9.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x454): undefined reference to `std::ios_base::Init::Init()'
test.cpp:(.text+0x463): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc0jWcv9.o: /tmp/ccVP6thR.o: In function `KDL::TreeElement::~TreeElement()':
test.cpp:(.text._ZN3KDL11TreeElementD2Ev[_ZN3KDL11TreeElementD5Ev]+0x26): undefined reference to `KDL::Segment::~Segment()'
/tmp/cc0jWcv9.o: In function `KDL::Tree::~Tree()':
test.cpp:(.text._ZN3KDL4TreeD2Ev[_ZN3KDL4TreeD5Ev]+0x23): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
test.cpp:(.text._ZN3KDL4TreeD2Ev[_ZN3KDL4TreeD5Ev]+0x48): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o: In function `KDL::Tree::~Tree()':
test.cpp:(.text._ZN3KDL4TreeD0Ev[_ZN3KDL4TreeD0Ev]+0x20): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o: In function `__gnu_cxx::new_allocator<std::_Rb_tree_const_iterator<std::pair<std::string const, KDL::TreeElement> > >::deallocate(std::_Rb_tree_const_iterator<std::pair<std::string const, KDL::TreeElement> >*, unsigned long)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt23_Rb_tree_const_iteratorISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m[_ZN9__gnu_cxx13new_allocatorISt23_Rb_tree_const_iteratorISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m]+0x1c): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o: In function `std::pair<std::string const, KDL::TreeElement>::~pair()':
test.cpp:(.text._ZNSt4pairIKSsN3KDL11TreeElementEED2Ev[_ZNSt4pairIKSsN3KDL11TreeElementEED5Ev]+0x24): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cc0jWcv9.o: In function `__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, KDL::TreeElement> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, KDL::TreeElement> >*, unsigned long)':
test.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m[_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsN3KDL11TreeElementEEEE10deallocateEPS7_m]+0x1c): undefined reference to `operator delete(void*)'
/tmp/cc0jWcv9.o:(.rodata._ZTIN3KDL4TreeE[_ZTIN3KDL4TreeE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/tmp/cc0jWcv9.o:(.eh_frame+0x10b): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
test@test:~/Desktop/calll/calling_so$

How to call these libraries from an external CPP without using ROS?

Calling ROS libraries from external CPP

I want to call the ROS libraries (shared object .so files) from external CPP program. Below are the ROS libraries-libraries, which I copied from /opt/ros/indigo/lib/ to a sub-directory-

  1. /opt/ros/indigo/lib/libkdl_parser.so
  2. /opt/ros/indigo/lib/liborocos-kdl.so.1.3.0

The I used g++ to compile the main code i.e., test.cpp looks like following-

#include <iostream>
#include <kdl/jntarray.hpp>
#include <kdl/chaindynparam.hpp>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/jntspaceinertiamatrix.hpp>

int main(int argc, char** argv)
{
    std::string urdf_file = "robot.urdf";
    std::string base_link = "base";
    std::string tip_link = "end_effector";

    KDL::Tree tree;
    if (!kdl_parser::treeFromFile(urdf_file, tree)) {
        printf("Failed to construct kdl tree\n");
        return -1;
    }

    KDL::Chain chain;
    if (!tree.getChain(base_link, tip_link, chain))
        printf("Couldn't find chain from %s to %s\n", base_link.c_str(), tip_link.c_str());

    KDL::ChainDynParam dyn(chain, KDL::Vector::Zero());

    KDL::JntArray q(chain.getNrOfJoints()); //dummy value
    KDL::JntSpaceInertiaMatrix H(chain.getNrOfJoints());
    dyn.JntToMass(q, H);

    printf("(0,0) element of Inertia Matrix %f\n", H(0,0));
    return 0;
}

The robot.urdf is kept along with test.cpp and headers are kept in a sub-directory. Below is the directory structure-

test@test:~/Desktop/calll/calling_so$ tree
.
├── robot.urdf
├── errors
├── include
│   ├── kdl
│   │   ├── articulatedbodyinertia.hpp
│   │   ├── chaindynparam.hpp
│   │   ├── chain.hpp
│   │   ├── chainidsolver.hpp
│   │   ├── chainidsolver_recursive_newton_euler.hpp
│   │   ├── config.h
│   │   ├── frames.hpp
│   │   ├── frames.inl
│   │   ├── jacobian.hpp
│   │   ├── jntarray.hpp
│   │   ├── jntspaceinertiamatrix.hpp
│   │   ├── joint.hpp
│   │   ├── rigidbodyinertia.hpp
│   │   ├── rotationalinertia.hpp
│   │   ├── segment.hpp
│   │   ├── tree.hpp
│   │   └── utilities
│   │       ├── kdl-config.h
│   │       └── utility.h
│   ├── kdl_parser
│   │   └── kdl_parser.hpp
│   ├── urdf
│   │   ├── model.h
│   │   └── urdfdom_compatibility.h
│   ├── urdf_exception
│   │   └── exception.h
│   └── urdf_model
│       ├── color.h
│       ├── joint.h
│       ├── link.h
│       ├── model.h
│       ├── pose.h
│       ├── types.h
│       └── utils.h
├── shared
│   ├── libkdl_parser.so
│   ├── liborocos-kdl.so -> liborocos-kdl.so.1.3
│   ├── liborocos-kdl.so.1.3 -> liborocos-kdl.so.1.3.0
│   └── liborocos-kdl.so.1.3.0
└── test.cpp

8 directories, 36 files

I used gcc to compile the test.cpp with following command-

g++ -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl -lkdl_parser -std=c++11 test.cpp -o test

but it is not working, since few more dependencies need to satisfy. Below is the error -

test@test:~/Desktop/calll/calling_so$ g++ -Iinclude -I/usr/include/eigen3 -Lshared -lorocos-kdl -lkdl_parser -std=c++11 test.cpp -o test
/tmp/ccVP6thR.o: In function `main':
test.cpp:(.text+0x103): undefined reference to `KDL::Tree::Tree(std::string const&)'
test.cpp:(.text+0x13a): undefined reference to `kdl_parser::treeFromFile(std::string const&, KDL::Tree&)'
test.cpp:(.text+0x164): undefined reference to `KDL::Chain::Chain()'
test.cpp:(.text+0x188): undefined reference to `KDL::Tree::getChain(std::string const&, std::string const&, KDL::Chain&) const'
test.cpp:(.text+0x1f4): undefined reference to `KDL::ChainDynParam::ChainDynParam(KDL::Chain const&, KDL::Vector)'
test.cpp:(.text+0x216): undefined reference to `KDL::JntArray::JntArray(unsigned int)'
test.cpp:(.text+0x238): undefined reference to `KDL::JntSpaceInertiaMatrix::JntSpaceInertiaMatrix(int)'
test.cpp:(.text+0x258): undefined reference to `KDL::ChainDynParam::JntToMass(KDL::JntArray const&, KDL::JntSpaceInertiaMatrix&)'
test.cpp:(.text+0x271): undefined reference to `KDL::JntSpaceInertiaMatrix::operator()(unsigned int, unsigned int)'
test.cpp:(.text+0x2a6): undefined reference to `KDL::JntSpaceInertiaMatrix::~JntSpaceInertiaMatrix()'
test.cpp:(.text+0x2b5): undefined reference to `KDL::JntArray::~JntArray()'
test.cpp:(.text+0x2c4): undefined reference to `KDL::ChainDynParam::~ChainDynParam()'
test.cpp:(.text+0x2d3): undefined reference to `KDL::Chain::~Chain()'
test.cpp:(.text+0x39b): undefined reference to `KDL::JntSpaceInertiaMatrix::~JntSpaceInertiaMatrix()'
test.cpp:(.text+0x3af): undefined reference to `KDL::JntArray::~JntArray()'
test.cpp:(.text+0x3c3): undefined reference to `KDL::ChainDynParam::~ChainDynParam()'
test.cpp:(.text+0x3d7): undefined reference to `KDL::Chain::~Chain()'
/tmp/ccVP6thR.o: In function `KDL::TreeElement::~TreeElement()':
test.cpp:(.text._ZN3KDL11TreeElementD2Ev[_ZN3KDL11TreeElementD5Ev]+0x26): undefined reference to `KDL::Segment::~Segment()'
collect2: error: ld returned 1 exit status
test@test:~/Desktop/calll/calling_so$

Below is test.cpp-

#include <iostream>
#include <kdl/jntarray.hpp>
#include <kdl/chaindynparam.hpp>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/jntspaceinertiamatrix.hpp>

int main(int argc, char** argv)
{
    std::string urdf_file = "robot.urdf";
    std::string base_link = "base";
    std::string tip_link = "end_effector";

    KDL::Tree tree;
    if (!kdl_parser::treeFromFile(urdf_file, tree)) {
        printf("Failed to construct kdl tree\n");
        return -1;
    }

    KDL::Chain chain;
    if (!tree.getChain(base_link, tip_link, chain))
        printf("Couldn't find chain from %s to %s\n", base_link.c_str(), tip_link.c_str());

    KDL::ChainDynParam dyn(chain, KDL::Vector::Zero());

    KDL::JntArray q(chain.getNrOfJoints()); //dummy value
    KDL::JntSpaceInertiaMatrix H(chain.getNrOfJoints());
    dyn.JntToMass(q, H);

    printf("(0,0) element of Inertia Matrix %f\n", H(0,0));
    return 0;
}

The robot.urdf is kept along with test.cpp and headers are kept in a sub-directory. Below is the directory structure-

test@test:~/Desktop/calll/calling_so$ tree
.
├── robot.urdf
├── errors
├── include
│   ├── kdl
│   │   ├── articulatedbodyinertia.hpp
│   │   ├── chaindynparam.hpp
│   │   ├── chain.hpp
│   │   ├── chainidsolver.hpp
│   │   ├── chainidsolver_recursive_newton_euler.hpp
│   │   ├── config.h
│   │   ├── frames.hpp
│   │   ├── frames.inl
│   │   ├── jacobian.hpp
│   │   ├── jntarray.hpp
│   │   ├── jntspaceinertiamatrix.hpp
│   │   ├── joint.hpp
│   │   ├── rigidbodyinertia.hpp
│   │   ├── rotationalinertia.hpp
│   │   ├── segment.hpp
│   │   ├── tree.hpp
│   │   └── utilities
│   │       ├── kdl-config.h
│   │       └── utility.h
│   ├── kdl_parser
│   │   └── kdl_parser.hpp
│   ├── urdf
│   │   ├── model.h
│   │   └── urdfdom_compatibility.h
│   ├── urdf_exception
│   │   └── exception.h
│   └── urdf_model
│       ├── color.h
│       ├── joint.h
│       ├── link.h
│       ├── model.h
│       ├── pose.h
│       ├── types.h
│       └── utils.h
├── shared
│   ├── libkdl_parser.so
│   ├── liborocos-kdl.so -> liborocos-kdl.so.1.3
│   ├── liborocos-kdl.so.1.3 -> liborocos-kdl.so.1.3.0
│   └── liborocos-kdl.so.1.3.0
└── test.cpp

8 directories, 36 files

How to call resolve this error so that these libraries can be called from an external CPP without using ROS?