title: How to use Scons to compile same objects in different environments with Glob?
body: <p>I have a C++ project builds with Scons.  At first I have only the optimized version to compile, it works fine. Then I also need a debug version, then I add another environment for it.  Here is the Scons code:</p>
  
  <pre><code>env = Environment()
  
  opt = env.Clone(CCFLAGS=['-pthread', '-O3', '-Wall'])
  opt_objs = opt.Glob('src/*.cpp')
  prog = opt.Program('prog', opt_objs)
  
  dbg = env.Clone(CCFLAGS=['-pthread', '-Wall', '-g', '-O0'])
  dbg_objs = dbg.Glob('src/*.cpp')
  dbg_prog = dbg.Program('dbg_prog', dbg_objs)
  </code></pre>
  
  <p>With this code, I ran into error:</p>
  
  <pre><code>scons: *** Two environments with different actions were specified for the same target: 
  src/CometReadService.o
  </code></pre>
  
  <p>As you can see, those .o files targets created by opt.Glob('src/<em>.cpp') and dbg.Glob('src/</em>.cpp') exactly same name.  By reading the document <a href="http://www.scons.org/doc/production/HTML/scons-user/x1436.html#AEN1578" rel="noreferrer">Multiple Construction Environments</a> I know I can rename the object like "opt.Object('xxx-opt', 'xxx.c')", but however, it is Glob not Object.  How can I solve this problem?  </p>