![](/img/trans.png)
[英]Failed to resolve cc1plus: error: unrecognized command line option “-std=c++11”
[英]cc1plus: error: unrecognized command line option “-std=c++11” with g++
我正在嘗試使用g++
和-std=c++11
或c++0x
標志進行編譯。
但是,我收到此錯誤
cc1plus: error: unrecognized command line option "-std=c++11"
g ++ --version
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
從您的G ++版本看,您需要更新它。 C ++ 11僅在G ++ 4.3之后才可用。 最新版本是4.7。
在pre-G ++ 4.7版本中,您必須使用-std=c++0x
,對於更新版本,您可以使用-std=c++11
。
引自gcc網站 :
C ++ 11特性作為GCC Subversion存儲庫主干和GCC 4.3及更高版本中“主線”GCC編譯器的一部分提供。 要啟用C ++ 0x支持,請將命令行參數-std = c ++ 0x添加到g ++命令行。 或者,要在C ++ 0x擴展之外啟用GNU擴展,請將-std = gnu ++ 0x添加到g ++命令行。 GCC 4.7及更高版本也支持-std = c ++ 11和-std = gnu ++ 11。
所以你可能使用的g ++版本不支持-std=c++11
。 請嘗試-std=c++0x
。
C ++ 11功能的可用性僅適用於版本> = 4.3。
你應該試試這個
g++-4.4 -std=c++0x or g++-4.7 -std=c++0x
我也得到了相同的錯誤,使用-D標志進行編譯修復它,試試這個:
g ++ -Dstd = c ++ 11
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.