Building workspace: error: '_GLIBCXX_NUM_CATEGORIES' was not declared in this scope
Following the tutorial "Creating a workspace" described here:
https://docs.ros.org/en/galactic/Tuto...
'colcon build' fails with lots of C++ errors.
My locale:
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
$ printenv | grep ROS
ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_LOCALHOST_ONLY=0
ROS_DISTRO=galactic
My installation type: ROS2 Galactic via Debian packages (sudo apt install).
My OS: Ubuntu 20.04
What goes wrong:
colcon build fails to build turtlesim with lots and lots of errors like this:
In file included from /usr/include/c++/9/locale:39,
from /usr/local/include/locale.h:11,
from /usr/include/c++/9/clocale:42,
from /usr/include/x86_64-linux-gnu/c++/9/bits/c++locale.h:41,
from /usr/include/c++/9/bits/localefwd.h:40,
from /usr/include/c++/9/string:43,
from /usr/include/c++/9/stdexcept:39,
from /usr/include/c++/9/array:39,
from /usr/include/c++/9/tuple:39,
from /usr/include/c++/9/bits/unique_ptr.h:37,
from /usr/include/c++/9/memory:80,
from /opt/ros/galactic/include/rosidl_runtime_cpp/bounded_vector.hpp:19,
from /home/me/dev_ws/build/turtlesim/rosidl_generator_cpp/turtlesim/action/detail/rotate_absolute__struct.hpp:8,
from /home/me/dev_ws/build/turtlesim/rosidl_typesupport_cpp/turtlesim/action/rotate_absolute__type_support.cpp:7:
/usr/include/c++/9/bits/locale_classes.h:333:37: error: ‘_GLIBCXX_NUM_CATEGORIES’ was not declared in this scope
333 | enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/locale_classes.h: In constructor ‘std::locale::locale(const string&)’:
/usr/include/c++/9/bits/locale_classes.h:163:45: error: invalid use of incomplete type ‘const string’ {aka ‘const class std::__cxx11::basic_string<char>’}
163 | locale(const std::string& __s) : locale(__s.c_str()) { }
| ^~~
In file included from /usr/include/c++/9/iosfwd:39,
from /usr/include/c++/9/memory:72,
from /opt/ros/galactic/include/rosidl_runtime_cpp/bounded_vector.hpp:19,
from /home/me/dev_ws/build/turtlesim/rosidl_generator_cpp/turtlesim/action/detail/rotate_absolute__struct.hpp:8,
from /home/me/dev_ws/build/turtlesim/rosidl_typesupport_cpp/turtlesim/action/rotate_absolute__type_support.cpp:7:
/usr/include/c++/9/bits/stringfwd.h:74:11: note: declaration of ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’}
74 | class basic_string;
| ^~~~~~~~~~~~
In file included from /usr/include/c++/9/locale:39,
from /usr/local/include/locale.h:11,
from /usr/include/c++/9/clocale:42,
from /usr/include/x86_64-linux-gnu/c++/9/bits/c++locale.h:41,
from /usr/include/c++/9/bits/localefwd.h:40,
from /usr/include/c++/9/string:43,
from /usr/include/c++/9/stdexcept:39,
from /usr/include/c++/9/array:39,
from /usr/include/c++/9/tuple:39,
from /usr/include/c++/9/bits/unique_ptr.h:37,
from /usr/include/c++/9/memory:80,
from /opt/ros/galactic/include/rosidl_runtime_cpp/bounded_vector.hpp:19,
from /home/me/dev_ws/build/turtlesim/rosidl_generator_cpp/turtlesim/action/detail/rotate_absolute__struct.hpp:8,
from /home/me/dev_ws/build/turtlesim/rosidl_typesupport_cpp/turtlesim/action/rotate_absolute__type_support.cpp:7:
<snip lots of errors> ...
seems to suggest this is a problem with your locale / language settings and/or configuration somewhere.
Searching for this error message (using Google) turns up quite some results.
This is not really a Colcon or ROS 2 problem I believe.
@gvdhoorn thanks for your answer but I showed my locale above: en_US.UTF-8. It seems to me that something is choosing the wrong C++ standard and/or headers, but this is a stock Ubuntu 20.04 install and ROS2 Galactic from Debian packages, so it should work out of the box. How can I debug this problem?
setting an env var and properly configuring locales are two different things.
_GLIBCXX_NUM_CATEGORIES
is#define
d in/usr/include/x86_64-linux-gnu/c++/9/bits/c++locale.h
or thereabouts. That would seem to point to a locale related issue.You don't include all error messages, so it could be the
_GLIBCXX_NUM_CATEGORIES
problem is a red herring and is due to an earlier parsing error. You'll have to check that yourself, as we can't determine that with what you've shown.what makes you conclude that?
_GLIBCXX_NUM_CATEGORIES
is "used" bystd::string
's headers, so if that fails, the rest ofstd::string
will also not parse correctly.