Ask Your Question
0

Compilation Wall of Errors Seemingly Unrelated to .cpp

asked 2018-08-15 14:50:24 -0500

Old Meme gravatar image

updated 2018-08-15 15:48:55 -0500

gvdhoorn gravatar image

Hi guys,

I've been writing a ROS publisher/subscriber node in C++ on ROS kinetic using a Navio2 board. When I attempt to compile, I don't get any syntax errors, but instead get a wall of errors involving dependencies, serializations, and whatnot:


CMakeFiles/roscomm.dir/src/roscomm.cpp.o: In function `imuCallback(boost::shared_ptr<sensor_msgs::Imu_<std::allocator<void> > const> const&)':                                                              
roscomm.cpp:(.text+0x868): undefined reference to `ros::NodeHandle::NodeHandle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<$
har, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, st$
::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::alloca$
or<char> > > > > const&)'                                                                                                                                                                                   
roscomm.cpp:(.text+0x8e4): undefined reference to `ros::Rate::Rate(double)'                                                                                                                                 
roscomm.cpp:(.text+0x978): undefined reference to `ros::console::initialize()'                                                                                                                              
roscomm.cpp:(.text+0x9c4): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, $
os::console::levels::Level)'                                                                                                                                                                                
roscomm.cpp:(.text+0xa08): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'                                                              
roscomm.cpp:(.text+0xa10): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'                                                                                       
roscomm.cpp:(.text+0xa78): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'                     
roscomm.cpp:(.text+0xa90): undefined reference to `ros::spinOnce()'                                                                                                                                         
roscomm.cpp:(.text+0xac0): undefined reference to `ros::Publisher::~Publisher()'                                                                                                                            
roscomm.cpp:(.text+0xacc): undefined reference to `ros::NodeHandle::~NodeHandle()'                                                                                                                          
roscomm.cpp:(.text+0xc08): undefined reference to `ros::Publisher::~Publisher()'                                                                                                                            
roscomm.cpp:(.text+0xc14): undefined reference to `ros::NodeHandle::~NodeHandle()'                                                                                                                          
roscomm.cpp:(.text+0xcf0): undefined reference to `ros::console::g_initialized'                                                                                                                             
CMakeFiles/roscomm.dir/src/roscomm.cpp.o: In function `main':                                                                                                                                               
roscomm.cpp:(.text+0xd54): undefined reference to `ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'                           
roscomm.cpp:(.text+0xd98): undefined reference to `ros::NodeHandle::NodeHandle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<$
har, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, st$
::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::alloca$
or<char> > > > > const&)'                                                                                                                                                                                   
roscomm.cpp:(.text+0xe3c): undefined reference to `ros::spin()'                                                                                                                                             
roscomm.cpp:(.text+0xe4c): undefined reference to `ros::Subscriber::~Subscriber()'                                                                                                                          
roscomm.cpp:(.text+0xe58): undefined reference to `ros::NodeHandle::~NodeHandle()'                                                                                                                          
roscomm.cpp:(.text+0xed4): undefined reference to `ros::Subscriber::~Subscriber()'                                                                                                                          
roscomm.cpp:(.text+0xee0): undefined reference to `ros::NodeHandle::~NodeHandle()'                                                                                                                          
CMakeFiles/roscomm.dir/src/roscomm.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':                                                                                                
roscomm.cpp:(.text+0xf48): undefined reference to `boost::system::generic_category()'                                                                                                                       
roscomm.cpp:(.text+0xf58): undefined ...
(more)
edit retag flag offensive close merge delete

Comments

This has most likely nothing to do with ROS, but with C++. C++11 to be specific.

Seeing all the references to basic_string and std::string, I'm wondering whether this is a C++11/C++03 ABI compatibility.

Are you enabling C++11 where you shouldn't, or aren't you when you should?

gvdhoorn gravatar image gvdhoorn  ( 2018-08-15 15:50:10 -0500 )edit

I can't really tell if I'm accidentally C++11, but I haven't used basic_string anywhere in my code. One thing that I did do that might be causing some issues is that I put a node handler within a callback function. Would that cause any issues?

Old Meme gravatar image Old Meme  ( 2018-08-16 08:08:21 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-08-16 08:36:33 -0500

Old Meme gravatar image

In my CMakeLists.txt file, I added target_link_libraries(roscomm ${catkin_LIBRARIES}) and everything's working now

edit flag offensive delete link more

Comments

I should have asked you for your CMakeLists.txt before making assumptions about C++11.

I was under the impression you already had everything setup for linking, but checking #q300573 we see that you link against catkin_INCLUDE_DIRS there, which won't work.

gvdhoorn gravatar image gvdhoorn  ( 2018-08-16 09:14:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-08-15 14:50:24 -0500

Seen: 803 times

Last updated: Aug 15 '18