【问题标题】:Compiling C++11 on g++ 4.4.7 in Red Hat linux [closed]在 Red Hat linux 中在 g++ 4.4.7 上编译 C++11 [关闭]
【发布时间】:2014-06-24 18:35:41
【问题描述】:

我已经试过了:

g++ -std=c++11 my_file.cpp -o my_prog
g++ -std=c++0x ...
g++ -std=gnu++0x ... 

我不断收到这条消息:

error: unrecognized command line option

【问题讨论】:

  • g++ 4.4.7 不支持 c++11 是吗?
  • which g++ 报告什么? g++ -v 报告了什么?

标签: c++11 compilation g++ redhat


【解决方案1】:

C++0x/C++11 Support in GCC

从那里您可以看到自 gcc 4.7 以来支持 C++11,而 gcc 4.4 支持 C++0x。

引用Status of Experimental C++0x Support in GCC 4.4:

GCC 为即将到来的 ISO C++ 标准提供实验性支持, C++0x。可以使用 -std=c++0x 或 -std=gnu++0x 启用此支持 编译器选项;前者禁用 GNU 扩展。

所以它应该与-std=c++0x-std=gnu++0x 一起使用。

【讨论】:

    【解决方案2】:

    不清楚你的问题是什么:

    [11:51am][wlynch@apple /tmp] cat /etc/redhat-release 
    CentOS release 6.5 (Final)
    [11:51am][wlynch@apple /tmp] g++ -v
    Using built-in specs.
    Target: x86_64-redhat-linux
    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
    Thread model: posix
    gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
    [11:51am][wlynch@apple /tmp] g++ -std=c++0x simple.cc 
    [11:51am][wlynch@apple /tmp]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-09
      • 1970-01-01
      • 1970-01-01
      • 2014-03-17
      • 1970-01-01
      • 2018-01-31
      • 2014-10-29
      相关资源
      最近更新 更多