【问题标题】:passing GCC flag -std=c++11 CXXFLAGS or CXX or CFLAGS传递 GCC 标志 -std=c++11 CXXFLAGS 或 CXX 或 CFLAGS
【发布时间】:2016-08-08 17:57:32
【问题描述】:

我真的需要一些帮助来解决一个基本问题。我将永远放弃学习 GCC,因为基础知识对我来说似乎没有意义。我已经阅读了数百篇帖子,但无法弄清楚如何通过configure 获得基本的-std=c++11 工作电话

在这个例子中,我编译了 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);

algorithm 似乎已从 gcc5.3 编译中正确安装。 请指出正确的方向来解决这些类型的错误。

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

【问题讨论】:

  • 您想在Makefile 中指定CXXFLAGS;然后该值将作为命令行选项传递给g++。但是由于Makefile 是由configure 脚本自动生成的,所以您的问题实际上是关于autotools,而不是gcc。
  • 我不知道 GCC 编译的拼写 :)

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


【解决方案1】:

std::rand是在<cstdlib>中定义的,和C++11没有关系,这个头文件很久以前就有了。检查源中是否为#included。

【讨论】:

  • 感谢您的指点,我得出这个结论是因为许多其他帖子表明需要添加 C++11 s aflag.i 将检查该包含。谢谢艺术
  • 我已经搜索过,但仍然不知道要寻找什么。 #included in the source.你指的是什么来源?我在 /include/ 主目录中有cstdlib
猜你喜欢
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 2014-06-17
  • 2016-07-08
  • 2014-01-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多