问题描述
我试图使用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'
库(lib_name,src_files)
我得到以下错误。看起来CXXFLAGS在调用g ++时没有生效:
g ++ -o test.o -c test.cc
在/usr/include/c++/4.8.2/unordered_map:35:0中包含的文件中,
来自test.cc:2:
/usr/include/c++/4.8.2/bits/ c ++ 0x_warning.h:32:2:error:#error此文件需要编译器和库支持ISO C ++ 2011标准。此支持目前是实验性的,必须使用-std = c ++ 11或-std = gnu ++ 11编译器选项来启用。
#error此文件需要编译器和库支持\
^
scons:*** [test.o]错误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)
I am trying to compile a c++ file with -std=c=+11 option using scons.
File : test.cc
#include <unordered_map>
int foo()
{ return 0; }
File : 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)
I am getting the following error. It seems CXXFLAGS is not taking effect when g++ is invoked:
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
I have read a few postings about compiling c++ files with -std=c++11 option by modifying the "Construction Environment", which I feel I have done. Can someone please help.
Thank you,Ahmed.
Use env.Library
instead of Library
to build the library with your construction environment.
env = Environment()
env.Append(CXXFLAGS = '-std=c++11')
src_files = Split('test.cc')
lib_name = 'test'
env.Library(lib_name, src_files)
这篇关于使用scons用-std = c ++ 11标志编译c ++文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!