3

I need to use data structures like unordered_map within my code in network simulator NS-3. It is using waf builder to compile the source code. I am confused that where should I add -std=c++0x to be added to compiler flags? I tried appending it to CXXFlags in main wscript file using:

module.env.append_value('CXXFLAGS', '-std=c++0x');

But still I am getting this error:

This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options. C/C++ Problem

Should I also add any library to my waf module as well?

P.S: My GCC version is 4.4

Update: After updating to 4.7 I get this error:

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.

Is there a way to tell compiler to use 0x instead of 11?

hashtpaa
  • 389
  • 2
  • 11
  • 4
    Have you considered using a GCC version that's more recent than 2 years ago? – Nicol Bolas Aug 09 '12 at 03:57
  • 1
    Try to get a newer version of GCC (I would say *at least* 4.6, but even 4.7.1 if you uses C++11). – Jaffa Aug 09 '12 at 07:52
  • @NicolBolas I updated my GCC and G++ to 4.7 and re-configured NS but now when it reaches the same point it gives this error: 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. – hashtpaa Aug 09 '12 at 20:00
  • Just to give an update. I was trying to compile NS3 on Ubuntu Server 12.04 LTS with GCC 4.7.2 Linaro tool-chain manually compiled and the "-std=c++11x" flag enabled. The number of errors this produces does indicate that NS3 is still incompatible with C++11. – Sebastian Apr 24 '13 at 10:13

1 Answers1

9

Here is the solution:

First of all upgrading GCC to 4.7 for Ns-3 will cause more errors due to changes in standard and does not solve the problem. So I changed gcc and g++ back to 4.4.3.

But in order to get rid of this error (as it says) this option should be added to CXXFLAGS:

-std=c++0x

To add an option to CXXFLAG you can use this:

CXXFLAGS="-std=c++0x" ./waf configure

or if you want to add options to waf configure:

CXXFLAGS="-std=c++0x" ./waf -d debug --enable-examples --enable-tests configure
hashtpaa
  • 389
  • 2
  • 11