0

I include a header file from a library in my source file and get this following error my initial guess is there is something wrong in CMakeLists any suggestions please

/usr/include/c++/4.8/bits/c++0_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard.

This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

#error This file requires compiler and library support for the

make[2]: *** [CMakeFiles..] Error 1

make[1]: *** [CMakeFiles..] Error 2

make: *** [all] Error 2

2017_John
  • 99
  • 2
  • 9
  • And have you tried doing what the compiler suggests? Also note that GCC version 4.8 is getting old now, and don't support all of C++11 and very little if anything at all of later standards. – Some programmer dude May 30 '17 at 13:11
  • Is there a direct way to update GCC version 4.8 to C++11 – 2017_John May 30 '17 at 13:21
  • Read the messages again, especially this part: "This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options." Have you tried adding the option `-std=c++11` when building? – Some programmer dude May 30 '17 at 13:24
  • It means I am suppose to compile it as follows make -std=c++11 or make -std=gnu++11 ? It didnt work as well – 2017_John May 30 '17 at 13:31

1 Answers1

2

As the error states:

/usr/include/c++/4.8/bits/c++0_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard.

You need to enable the C++11 support. You can do this in the CMakeLists.txt by writing the following line

add_definitions(-std=c++11)

And recompiling.

Also beware that GCC 4.8 has limited support for C++11, you can check the support here.

maetulj
  • 1,032
  • 1
  • 9
  • 15
  • Thanks alot. It helped alot. There is another obstacle here i.e to include a static library with the extension .a Any idea what to write in CMakeLists.txt in order to include the following Makefile command LIB_NAME = AdsLib-$(OS_NAME).a – 2017_John May 30 '17 at 14:24
  • uff, that would require a long answer, but you can just look here for an example http://docs.ros.org/jade/api/catkin/html/howto/format2/system_library_dependencies.html for some hints. – maetulj May 31 '17 at 09:58