Reputation: 3652
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.
Upvotes: 3
Views: 3339
Reputation: 15972
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)
Upvotes: 4