c++ - 如何构建 NS-3 以使用 C++0x/C++11 库?

标签 c++ gcc c++11 waf ns-3

我需要在网络模拟器 NS-3 的代码中使用像 unordered_map 这样的数据结构。 它使用waf builder编译源代码。 我很困惑我应该在哪里添加 -std=c++0x 以添加到编译器标志? 我尝试使用以下方法将它附加到主 wscript 文件中的 CXXFlags:

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

但我仍然收到此错误:

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

我还应该向我的 waf 模块添加任何库吗?

P.S: 我的 GCC 版本是 4.4

更新:更新到 4.7 后出现此错误:

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.

有没有办法告诉编译器使用 0x 而不是 11?

最佳答案

解决方法如下:

首先将Ns-3的GCC升级到4.7会因为标准的变化导致更多的错误,并不能解决问题。所以我将 gcc 和 g++ 改回 4.4.3。

但是为了摆脱这个错误(正如它所说的)这个选项应该添加到 CXXFLAGS:

-std=c++0x

要向 CXXFLAG 添加选项,您可以使用:

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

或者如果你想为 waf 配置添加选项:

CXXFLAGS="-std=c++0x" ./waf -d debug --enable-examples --enable-tests configure

关于c++ - 如何构建 NS-3 以使用 C++0x/C++11 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11876088/

相关文章:

c++ - 初学者的 opengl 多纹理

C++ "...does not name a type"

gcc - 使用-pg编译时更改gmon.out文件的名称

c++ - 使用 cv::Mat1f 作为 cv::Mat

c++ - 如何在 C++ 中对任何函数进行 typedef?

c++ - 来自设备纹理阵列的 NVIDIA CUDA 视频编码器 (NVCUVENC) 输入

c++ - 使用 C++ 中的属性管理大型空间数据集

c++ - (Visual C++) 删除指针后动态分配内存不是有效指针

c - 我有以下 gcc 编译警告

c++ - "__cplusplus"宏扩展成什么?