Hi ROS Community,
I am currently getting a "undefined reference" error when my ROS node is linking.
Here is my setup:
I have a ROS node that calls a library that I made, that is NOT built with ROS or inside the catkin build system.
My library that I built uses a third party system library that you can "apt-get install". For reference this is the " XML-RPC for C and C++" library found here http://xmlrpc-c.sourceforge.net/
The problem:
The library that I made builds fine. Both a ".a" and ".so" file. So it is able to find the xmlrpc system library just fine.
When I try to build my ROS node that instantiates my library, everything builds fine, but when it gets to the linking step, it comes up with a bunch of "undefined references" to the xmlrpc library. So I know it knows the location of my library, because the build would fail, not just the linking part.
Conclusion:
In my CMakeLists.txt, I included all the xmlrpc libraries under the "target_link_libraries()" macro and it can find these libraries as it does not complain that it can't find one of them. Here is what it looks like:
## Specify libraries to link a library or executable target against
target_link_libraries(my_ros_executables name_node
xmlrpc++
xmlrpc
xmlrpc_abyss
xmlrpc_client++
xmlrpc_client
xmlrpc_packetsocket
xmlrpc_server
xmlrpc_server++
xmlrpc_server_abyss
xmlrpc_server_abyss++
xmlrpc_server_cgi
xmlrpc_server_cgi++
xmlrpc_server_pstream++
xmlrpc_util
xmlrpc_xmlparse
xmlrpc_xmltok
my_library
${catkin_LIBRARIES}
)
Is there another way that you need to tell Catkin about a secondary library or a library that is called by a library that you instantiate in your ROS node, besides the target_link_libraries?
I also built my application with another build system and everything compiled and linked fine, so it has to be something with catkin.
Update
I just wanted to add that I also had "link_directories()" pointing to my library. The xmlrpc library shows up in /usr/lib and /usr/include/xmlrpc-c
What specific xmlrpc library does ROS use? I know there are a few such as:
XmlRpc++: http://sourceforge.net/projects/xmlrpcpp/
XML-RPC for C and C++: http://xmlrpc-c.sourceforge.net/
Here are the errors I am getting:
Linking CXX executable..../../my_ROS_node
my_library.so: undefined reference to `xmlrpc_c::value_int::value_int(xmlrpc_c::value)'
my_library.so: undefined reference to `xmlrpc_c::clientXmlTransport_curl::constrOpt::~constrOpt()'
my_library.so: undefined reference to `xmlrpc_c::paramList::paramList(unsigned int)'
my_library.so: undefined reference to `vtable for xmlrpc_c::rpcPtr'
my_library.so: undefined reference to `xmlrpc_c::value::~value()'
my_library.so: undefined reference to `xmlrpc_c::rpcPtr::operator->() const'
my_library.so: undefined reference to `xmlrpc_c::clientTransactionPtr::~clientTransactionPtr()'
my_library.so: undefined reference to `xmlrpc_c::value::~value()'
my_library.so: undefined reference to `xmlrpc_c::value_string::operator std::basic_string<char, std::char_traits<char>, std::allocator<char> >() const'
my_library.so: undefined reference to `xmlrpc_c::value_int::operator int() const'
my_library.so: undefined reference to `xmlrpc_c::clientXmlTransport_curl::constrOpt::constrOpt()'
my_library.so: undefined reference to `xmlrpc_c::paramList::add(xmlrpc_c::value)'
my_library.so: undefined reference to `xmlrpc_c::clientXmlTransport_curl::constrOpt::timeout(unsigned int const&)'
my_library.so: undefined reference to `xmlrpc_c::value_int::value_int(int)'
my_library.so: undefined reference to `xmlrpc_c::clientXmlTransport_curl::clientXmlTransport_curl(xmlrpc_c::clientXmlTransport_curl::constrOpt const&)'
my_library.so: undefined reference to `xmlrpc_c::value_string::value_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
my_library.so: undefined reference to `xmlrpc_c::value::value(xmlrpc_c::value const&)'
my_library.so: undefined reference to `xmlrpc_c::clientXmlTransport_curl::constrOpt::user_agent(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
my_library.so: undefined reference to `xmlrpc_c::value_string::value_string(xmlrpc_c::value)'
my_library.so: undefined reference to `xmlrpc_c::carriageParm_curl0::carriageParm_curl0(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
my_library.so: undefined reference to `xmlrpc_c::value_array::value_array(xmlrpc_c::value)'
my_library.so: undefined reference to `xmlrpc_c::rpc::getResult() const'
my_library.so: undefined reference to `xmlrpc_c::value_array::vectorValueValue() const'
my_library.so: undefined reference to `xmlrpc_c::rpc::call(xmlrpc_c::client*, xmlrpc_c::carriageParm*)'
my_library.so: undefined reference to `xmlrpc_c::rpcPtr::rpcPtr(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, xmlrpc_c::paramList const&)'
my_library.so: undefined reference to `xmlrpc_c::client_xml::client_xml(xmlrpc_c::clientXmlTransport*)'
collect2: ld returned 1 exit status
Maybe it is a version problem with roscpp and my library? Is there a work around for this case?
Originally posted by Raptor on ROS Answers with karma: 377 on 2013-07-08
Post score: 1
Original comments
Comment by dornhege on 2013-07-08:
Your assumption isn't fully correct: If the build succeeds and the link fails this means only the it knows the includes/headers of your library correctly. The link directory might still be wrong/missing. You should get a specific error when linking my_library then.
Comment by Raptor on 2013-07-08:
Thank you for your help. See update.
Comment by Raptor on 2013-07-08:
It looks like ROS uses the xmlrpc++ library, which is different then the XML-RPC for C and C++ library. The links are found under updates above. ROS calls the node xmlrpcpp: http://ros.org/wiki/xmlrpcpp
Comment by 130s on 2013-07-08:
@Raptor just fyi, you might want to avoid using link_directories
? I found cmake
doc says that "the command is rarely necessary".
Comment by Raptor on 2013-07-08:
How else would you link against non-ROS and non-system libraries that are not in your path?
Comment by joq on 2013-07-08:
This should work: http://ros.org/doc/groovy/api/catkin/html/howto/system_library_dependencies.html