Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++11 使用scon编译c++;使用-std=c++;11旗 我试图用sCONS.编译一个带有-STD= C++=11选项的C++文件。_C++11_Scons - Fatal编程技术网

C++11 使用scon编译c++;使用-std=c++;11旗 我试图用sCONS.编译一个带有-STD= C++=11选项的C++文件。

C++11 使用scon编译c++;使用-std=c++;11旗 我试图用sCONS.编译一个带有-STD= C++=11选项的C++文件。,c++11,scons,C++11,Scons,文件:test.cc #include <unordered_map> int foo() { return 0; } 我得到以下错误。调用g++时,CXXFLAGS似乎没有生效: g++ -o test.o -c test.cc In file included from /usr/include/c++/4.8.2/unordered_map:35:0, from test.cc:2: /usr/include/c++/4.8.2/bits/

文件:test.cc

#include <unordered_map>

int foo()
{ return 0; }
我得到以下错误。调用g++时,CXXFLAGS似乎没有生效:

g++ -o test.o -c test.cc
In file included from /usr/include/c++/4.8.2/unordered_map:35:0,
                 from test.cc:2:
/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
scons: *** [test.o] Error 1
我已经阅读了一些关于用-STD+C++ 11选项编译C++文件的帖子,这些文章通过修改我所做的“构建环境”来完成。有人能帮忙吗

谢谢,,
Ahmed.

使用
env.Library
而不是
Library
来使用构建环境构建库

env = Environment()
env.Append(CXXFLAGS = '-std=c++11')

src_files = Split('test.cc')
lib_name = 'test'

env.Library(lib_name, src_files)

很好,谢谢你。“图书馆”和“环境图书馆”有什么区别。后者是否使用不同的“构建环境”(即我实例化和修改的环境)?正确。库使用默认环境,而env.Library(或通常为env.\u Builder)使用环境env。
env = Environment()
env.Append(CXXFLAGS = '-std=c++11')

src_files = Split('test.cc')
lib_name = 'test'

env.Library(lib_name, src_files)