Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3336448
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:08:12+00:00 2026-05-18T00:08:12+00:00

I have a C++ project builds with Scons. At first I have only the

  • 0

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:

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)

With this code, I ran into error:

scons: *** Two environments with different actions were specified for the same target: 
src/CometReadService.o

As you can see, those .o files targets created by opt.Glob(‘src/.cpp’) and dbg.Glob(‘src/.cpp’) exactly same name. By reading the document Multiple Construction Environments 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:08:13+00:00Added an answer on May 18, 2026 at 12:08 am

    The scons manual describes how to use the VariantDir function (or argument when adding SConscripts) to set up different build directories. At its simplest, VariantDir separates the build output from the source files, but it can also be used to separate the build output of different environments.

    env = Environment()
    
    opt = env.Clone(CCFLAGS=['-pthread', '-O3', '-Wall'])
    opt.VariantDir('gen-opt', 'src', duplicate=0)
    opt_objs = opt.Glob('gen-opt/*.cpp')
    prog = opt.Program('prog', opt_objs)
    
    dbg = env.Clone(CCFLAGS=['-pthread', '-Wall', '-g', '-O0'])
    dbg.VariantDir('gen-dbg', 'src', duplicate=0)
    dbg_objs = dbg.Glob('gen-dbg/*.cpp')
    dbg_prog = dbg.Program('dbg_prog', dbg_objs)
    

    Using VariantDir can take some experimentation. For instance, note that the Glob argument has changed — without the duplicate=0 parameter, the default behavior is for VariantDir to duplicate the source files in the build directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that builds fine If I build it manually but it
I have an MsBuild project which builds various solutions and then copies the output
I have a project with a post build event: copy $(ProjectDir)DbVerse\Lunaverse.DbVerse.*.exe $(TargetDir) It works
I have this large C++ project that I need to build on a platform
I have an SCons project set up as follows: Project/ SConstruct # SConscript('stuff/SConscript', variant_dir
I'm using a MinGW-based GCC cross-compiler to compile a project which uses SCons as
I have a project where I need the JNLP API . I did not
I have a project that builds in 32/64-bit and has corresponding 32/64-bit dependencies. I
My Solution/Project builds fine with code contracts turned off for this particular project. When
I have a project with Crystal Reports files that doesn't seem to build correctly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.