传递GCC标志-std = c ++ 11 CXXFLAGS或CXX或CFLAGS

时间:2016-04-16 20:46:20

标签: c++ c++11 gcc makefile

我真的需要一些基本问题的帮助。我将永远放弃学习GCC,因为看起来基础知识对我来说没有意义。我已阅读了数百篇帖子,无法弄清楚如何通过-std=c++11

传递基本的configure来电。

在这个例子中我已经编译了gcc 5.3并且大多数程序编译正常,例如从源代码编译httpd没有问题。但我不断收到与我认为-std=c++11相关的错误。我读过的所有帖子都说要通过-std=c++11而我已经尝试了

CXXFLAGS=-std=c++11 
CXX=-std=c++11 
CFLAGS=-std=c++11

但错误仍然存​​在。

我现在正在尝试编译aspell,并收到以下错误,

In file included from /home/mybin/include/algorithm:62:0,
                 from /home/atmp/aspell-0.60.6.1/common/string.hpp:13,
                 from /home/atmp/aspell-0.60.6.1/common/indiv_filter.hpp:12,
                 from /home/atmp/aspell-0.60.6.1/modules/filter/email.cpp:9:
/home/mybin/include/bits/stl_algo.h: In function ‘void std::random_shuffle(_RAIter, _RAIter)’:
/home/mybin/include/bits/stl_algo.h:4448:8: error: ‘rand’ is not a member of ‘std’
      + std::rand() % ((__i - __first) + 1);
似乎已经从gcc5.3编译中正确安装了

algorithm。 请指出我正确的方向来解决这些类型的错误。

编译GCC时是否错过了编译选项?

1 个答案:

答案 0 :(得分:1)

std::rand<cstdlib>中定义,它与C ++ 11无关,这个标题很久以前就存在了。检查源中是#include d。