A myriad of libboost errors caused in tf or ros::param::get due to std::tuple declaration? Fix -std=c++11??
Ubuntu 16.04 ROS Kinetic DPKG states libboost1.58 for all libraries, catkin_make states libboost 1.50
Very recently I decided to clear /build and /devel and rebuild my workspace. A large list of boost errors for almost every package came out.
I see these errors start in multiple ros binaries:
ros::param::get <- tf/listener.h <- tf.h <- boost/tuple.hpp
tf/transform_broadcaster.h <- tf.h <- boost/signals2.hpp <- c++/5/tuple
Some of the error descriptions are included below:
from /usr/include/c++/5/tuple:35:0,
from /usr/local/include/boost/signals2/detail/variadic_slot_invoker.hpp ... error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or enter code here-std=gnu++11 compiler options.
from /usr/local/include/boost/signals2/variadic_signal.hpp:21:0,
from /usr/local/include/boost/signals2/signal.hpp:38 ... /usr/local/include/boost/signals2/detail/variadic_slot_invoker.hpp:68:41: error: ‘std::tuple’ has not been declared
R operator()(Func &func, std::tuple<Args...> args) const
And
/usr/local/include/boost/signals2/detail/variadic_slot_invoker.hpp: In member function ‘R boost::signals2::detail::call_with_tuple_args<R>::m_invoke(T*, Func&, boost::signals2::detail::unsigned_meta_array<indices ...>, int) const’:
/usr/local/include/boost/signals2/detail/variadic_slot_invoker.hpp:78:23: error: ‘get’ is not a member of ‘std’
return func(std::get<indices>(args)...);
OR
from /usr/local/include/boost/signals2/detail/variadic_slot_invoker.hpp:22...
error: ‘std::tuple’ has not been declared
R operator()(Func &func, std::tuple<Args...> args) const
I believe the error might be related to the condition described below:
The C++ standard doesn't allow a user to add forward declarations or definitions into namespace std. Adding declarations or definitions to namespace std or to a namespace within namespace std now results in undefined behavior.
At some time in the future, Microsoft will move the location where some STL types are defined. When this happens, it will break existing code that adds forward declarations to namespace std. A new warning, C4643, helps identify such source issues. The warning is enabled in /default mode and is off by default. It will impact programs that are compiled with /Wall or /WX
People have suggested adding the following compile options to a package's CMakeLists.txt:
addcompileoptions(-std=c++11)
And
set(CMAKECXXFLAGS "-std=c++11 ${CMAKECXXFLAGS}")
This solution seems only partial. Some packages display other libboost errors after this. Even if it were to work, it seems undesirable, as I would have to add this flag across hundreds of packages.
Are others experiencing these problems? Did this result from changes to C? A new standard? Any good solutions?
Asked by Juan on 2019-04-04 03:20:52 UTC
Answers
I see this in the output you post:
/usr/local/include/boost/[..]
this implies that you have a "custom" install of Boost (probably built from sources) on that system.
All binary ROS packages will have been built using the system provided (ie: Ubuntu) version of Boost. Mixing-and-matching Boost versions will lead to (sometimes very) hard to diagnose issues, and is not really supported.
And yes: every package using C++11 features will have to enable them explicitly (at least on Ubuntu Xenial, which ships GCC 4.8.1 by default). Many ROS packages for Kinetic already.
I'd suggest to first clarify the situation with Boost on your system, then diagnose further.
Asked by gvdhoorn on 2019-04-04 05:08:30 UTC
Comments
My apologies. I had installed an older version of boost in my system (1.50.0). This installation created conflicts with the current 1.58.0 boost version for Ubuntu 16.04. Once removed everything built fine.
Asked by Juan on 2019-04-04 22:50:00 UTC
Comments
The propper way to enable C++11 with CMake is
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON)
. Any other method will lead to problems at some point.Asked by VictorLamoine on 2019-04-04 03:33:49 UTC
Are you aware of any conflicts between ros/boost/tuple or new C standards?
Asked by Juan on 2019-04-04 04:10:01 UTC
Should I try to set my libboost_thread.so to version 1.50?
i.e. From
If I do I get the following warning:
But it seems to resolve all the boost errors...
Asked by Juan on 2019-04-04 04:43:21 UTC