简体   繁体   English

无法解析cc1plus:错误:无法识别的命令行选项“ -std = c ++ 11”

[英]Failed to resolve cc1plus: error: unrecognized command line option “-std=c++11”

I tried compiling the below program with "g++ -std=c++11 -ow w.cpp" and geting the error " cc1plus: error: unrecognized command line option "-std=c++11" ". 我尝试使用“ g ++ -std = c ++ 11 -ow w.cpp”编译以下程序,并得到错误“ cc1plus:错误:无法识别的命令行选项“ -std = c ++ 11””。 Tried compiling with g++ -Dstd=c++11 -ow w.cpp and getting the below set of errors: 尝试使用g ++ -Dstd = c ++ 11 -ow w.cpp进行编译,并获得以下错误集:

In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:41,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
                 from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stringfwd.h:42: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stringfwd.h:42: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:44,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:42,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:42,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
                 from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef:49: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef:49: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:42,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:42,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
                 from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:65: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:65: error: expected unqualified-id before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:139: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:139: error: expected unqualified-id before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:245: error: ‘::wcstold’ has not been declared
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:254: error: ‘::wcstoll’ has not been declared
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:255: error: ‘::wcstoull’ has not been declared
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:260: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:260: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:42,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
                 from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:70: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:70: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:40,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
                 from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected declaration before end of line

program- w.cpp

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int read_words(vector<string>& words, ifstream& in)
{
  int i = 0;
  while(!in.eof())
    in >> words[i++];
  return i-1;
}

int main()
{
  ifstream ifp("names");

  vector<string> w(500);
  int number_of_words = read_words(w, ifp);
  w.resize(number_of_words);

  for(auto it : w)
    cout << it << " ";
  cout << endl;

  map<string, string> wMap;

  for(int i = 0; i  <  number_of_words;) {
    wMap.insert(pair<string, string>(w[i], w[i+1]));
    i += 2;
  }

  cout << "wMap.size()=" << wMap.size() << endl;
  for(auto it = wMap.begin(); it != wMap.end(); it++)
    cout <<  it->first << " " << it->second << endl;
}

gcc Version: gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3) g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3) gcc版本:gcc(GCC)4.4.7 20120313(Red Hat 4.4.7-3)g ++(GCC)4.4.7 20120313(Red Hat 4.4.7-3)

Please help me to sought out this issue. 请帮助我解决这个问题。

-std=c++11 is only supported by GCC 4.7 and later. -std=c++11仅受GCC 4.7及更高版本支持。 For other versions, you can use std=c++0x (available since GCC 4.3). 对于其他版本,可以使用std=c++0x (自GCC 4.3起可用)。 See GCC's overview on 'C++0x/C++11 Support in GCC' for more information about C++11 support in different GCC versions. 有关不同GCC版本中C ++ 11支持的更多信息,请参见GCC关于 GCC中的C ++ 0x / C ++ 11支持”的概述。

对于低于4.7的gcc版本,您需要使用-std=c++0x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 cc1plus:错误:使用g ++无法识别的命令行选项“-std = c ++ 11” - cc1plus: error: unrecognized command line option “-std=c++11” with g++ cc1plus:错误:无法识别的命令行选项“ -std = gnu ++ 11” - cc1plus: error: unrecognized command line option “-std=gnu++11” cc1plus.exe:错误:无法识别的命令行选项&#39;-std = c ++ 11&#39;Netbeans 7 - cc1plus.exe: error: unrecognized command line option '-std=c++11' Netbeans 7 cc1plus:错误:无法识别的命令行选项“-std=c++0x” - cc1plus: error: unrecognized command line option "-std=c++0x" cc1plus:错误:hxcpp无法识别的命令行选项“ -stdlib = libstdc ++” - cc1plus: error: unrecognized command line option “-stdlib=libstdc++” with hxcpp cc1plus:错误:无法识别的命令行选项“ -Wno-implicit-fallthrough” [-Werror] - cc1plus: error: unrecognized command line option “-Wno-implicit-fallthrough” [-Werror] cc1plus:错误:无法识别的命令行选项“ -fsysroot = <path> ”和g ++ - cc1plus: error: unrecognized command line option “-fsysroot=<path>” with g++ 为什么我得到cc1plus:错误:无法识别的命令行选项“-arch”? - Why do I get cc1plus: error: unrecognized command line option “-arch”? 无法识别的命令行选项&#39;-std = c ++ 11&#39; - unrecognized command line option '-std=c++11' 无法识别的命令行选项“-std = c ++ 11” - unrecognized command line option “-std=c++11”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM