Compilation Wall of Errors Seemingly Unrelated to .cpp
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 ...
This has most likely nothing to do with ROS, but with C++. C++11 to be specific.
Seeing all the references to
basic_string
andstd::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?
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?