Unrecognized command line option ‘-std=c++11’

g++raspbianraspbian-wheezyros

As part of installing ROS on rasbian (wheezy) I'm having to install console-bridge manually. I'm running into an issue at

cc1plus: error: unrecognized command line option ‘-std=c++11’

From what I can tell this is due to an outdated g++ but when I try to update it:

$ sudo apt-get install --only-upgrade g++
Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

What can I do to get past this issue?

$ apt-get source -b console-bridge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
NOTICE: 'console-bridge' packaging is maintained in the 'Git' version control system at:
git://anonscm.debian.org/debian-science/packages/console-bridge.git
Skipping already downloaded file 'console-bridge_0.3.2-1.dsc'
Skipping already downloaded file 'console-bridge_0.3.2.orig.tar.gz'
Skipping already downloaded file 'console-bridge_0.3.2-1.debian.tar.xz'
Need to get 0 B of source archives.
Skipping unpack of already unpacked source in console-bridge-0.3.2
dpkg-buildpackage: source package console-bridge
dpkg-buildpackage: source version 0.3.2-1
dpkg-buildpackage: source changed by Jose Luis Rivero <jrivero@osrfoundation.org>
dpkg-buildpackage: host architecture armhf
 dpkg-source --before-build console-bridge-0.3.2
 fakeroot debian/rules clean
dh  clean --parallel
   dh_testdir -O--parallel
   debian/rules override_dh_auto_clean
make[1]: Entering directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2'
rm -f console_bridge-config.cmake
rm -f console_bridge.pc
dh_auto_clean --
make[1]: Leaving directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2'
   dh_clean -O--parallel
 debian/rules build
dh  build --parallel
   dh_testdir -O--parallel
   dh_auto_configure -O--parallel
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- console_bridge version 0.3.0
-- Performing Test HAS_VISIBILITY
-- Performing Test HAS_VISIBILITY - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf
   dh_auto_build -O--parallel
make[1]: Entering directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
/usr/bin/cmake -H/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2 -B/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf/CMakeFiles /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[2]: Entering directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
make -f CMakeFiles/console_bridge.dir/build.make CMakeFiles/console_bridge.dir/depend
make[3]: Entering directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
cd /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2 /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2 /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf/CMakeFiles/console_bridge.dir/DependInfo.cmake --color=
Scanning dependencies of target console_bridge
make[3]: Leaving directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
make -f CMakeFiles/console_bridge.dir/build.make CMakeFiles/console_bridge.dir/build
make[3]: Entering directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
/usr/bin/cmake -E cmake_progress_report /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf/CMakeFiles 2
[ 25%] Building CXX object CMakeFiles/console_bridge.dir/src/console.cpp.o
/usr/bin/c++   -Dconsole_bridge_EXPORTS -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2  -fvisibility=hidden -std=c++11 -Wall -Wextra -O3 -DNDEBUG -fPIC -I/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/include    -o CMakeFiles/console_bridge.dir/src/console.cpp.o -c /home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/src/console.cpp
cc1plus: error: unrecognized command line option ‘-std=c++11’
CMakeFiles/console_bridge.dir/build.make:57: recipe for target 'CMakeFiles/console_bridge.dir/src/console.cpp.o' failed
make[3]: *** [CMakeFiles/console_bridge.dir/src/console.cpp.o] Error 1
make[3]: Leaving directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
CMakeFiles/Makefile2:63: recipe for target 'CMakeFiles/console_bridge.dir/all' failed
make[2]: *** [CMakeFiles/console_bridge.dir/all] Error 2
make[2]: Leaving directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
Makefile:126: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/pi/ros_catkin_ws/external_src/console-bridge-0.3.2/obj-arm-linux-gnueabihf'
dh_auto_build: make -j1 returned exit code 2
debian/rules:7: recipe for target 'build' failed
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
Build command 'cd console-bridge-0.3.2 && dpkg-buildpackage -b -uc' failed.
E: Child process failed

Solution

inside console-bridge-0.3.2/CMakeLists.txt I found the following line:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")

Which I changed to:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra")

After making the change I could run

$ apt-get source -b console-bridge

with no errors.

Best Answer

GCC 4.6 series is rather old (2011-2012). It was first released when C++11 was still called C++0x, so it supports -std=c++0x switch rather than std=c++11. Its support of C++11 is rather incomplete, so more modern code which uses C++11 features heavily may or may not compile.

Related Topic