我正在尝试使用scons编译带有-std = c = + 11选项的c ++文件。
文件:test.cc
#include <unordered_map>
int foo()
{ return 0; }
文件:SConstruct
env = Environment()
env.Append(CXXFLAGS = '-std=c++11')
#print env['CXXFLAGS']
src_files = Split('test.cc')
lib_name = 'test'
Library(lib_name, src_files)
我收到以下错误。调用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 ++文件的帖子,修改了“构建环境”,我觉得我已经完成了。有人可以帮忙。
谢谢你, 艾哈迈德。
答案 0 :(得分:3)
使用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)