Possible Linking conflict with ROS and json_spirit
OS: Ubuntu 12.04 64-bit
ROS version: Hydro
GCC version: 4.6.3
I've been having getting some nasty linking errors when trying to use both jsonreader and ros subscriber nodes. I have boiled the problem in the program to the code below. Simply commenting out the subscriber assignment or the jsonspirit:: read call the program will build fine, it is only when both are compiled that I get the error at the bottom of this post. As far as I could find, it seems like it might be an inheritance problem with both jsonspiritreader and ROS both having some non virtual dependency that causes some sort of conflict. I could be wrong.
int main(int argc, char* argv[])
{
ros::init(argc, argv, "test_node");
ros::NodeHandle n;
ros::Subscriber sub ;
sub = n.subscribe("message", 3, callback);
ifstream foo;
json_spirit::Value bar;
json_spirit::read(foo, bar);
}
Linker error:
`.text._ZN5boost16exception_detail19error_info_injectorINS_17bad_function_callEED2Ev' referenced in section `.text._ZN5boost16exception_detail19error_info_injectorINS_17bad_function_callEED1Ev[non-virtual thunk to boost::exception_detail::error_info_injector<boost::bad_function_call>::~error_info_injector()]' of /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libjson_spirit.a(json_spirit_reader.cpp.o): defined in discarded section `.text._ZN5boost16exception_detail19error_info_injectorINS_17bad_function_callEED2Ev[_ZN5boost16exception_detail19error_info_injectorINS_17bad_function_callEED5Ev]' of /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libjson_spirit.a(json_spirit_reader.cpp.o)
`.text._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED2Ev' referenced in section `.text._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED1Ev[non-virtual thunk to boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >::~clone_impl()]' of /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libjson_spirit.a(json_spirit_reader.cpp.o): defined in discarded section `.text._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED2Ev[_ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED5Ev]' of /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libjson_spirit.a(json_spirit_reader.cpp.o)
`.text._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED2Ev' referenced in section `.text._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED1Ev[non-virtual thunk to boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >::~clone_impl()]' of /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libjson_spirit.a(json_spirit_reader.cpp.o): defined in discarded section `.text._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED2Ev[_ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_17bad_function_callEEEED5Ev]' of /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libjson_spirit.a(json_spirit_reader.cpp.o)
collect2: ld returned 1 exit status
Edit: Full code and cmake text
Code:
#include "ros/ros.h"
#include "fstream"
#include "json_spirit.h"
#include "std_msgs/String.h"
using namespace std;
void callback(const std_msgs::String::ConstPtr& msg)
{
}
int main(int argc, char* argv[]) {
ros::init(argc, argv, "test_node");
ros::NodeHandle n;
ros::Subscriber sub ;
sub = n.subscribe("message", 3, callback);
ifstream foo;
json_spirit::Value bar;
json_spirit::read(foo, bar);
}
cmake:
find_package(catkin REQUIRED COMPONENTS
roscpp
)
add_executable(json_test src/json_test.cpp)
#add_dependencies(json_test ${catkin_EXPORTED_TARGETS})
add_dependencies(json_test boost_program_options ${catkin_EXPORTED_TARGETS} zanni_generate_messages )
target_link_libraries(json_test
json_spirit
${catkin_LIBRARIES}
)
Asked by DraconicDon on 2014-07-07 15:24:43 UTC
Comments
I'd recommend posting the full C++ file (including header includes) and the CMakeLists.txt so that someone can reproduce this.
Asked by fergs on 2014-07-07 15:37:35 UTC
Question edited to add the requested information.
Asked by DraconicDon on 2014-07-07 17:12:24 UTC