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

  • SEARCH
  • Home
  • 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 3454412
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:29:25+00:00 2026-05-18T09:29:25+00:00

I have an existing C library that’s built with scons (the library has it’s

  • 0

I have an existing C library that’s built with scons (the library has it’s own
SConscript). This code now contains two variations controlled by #ifdefs. How
do I tell scons to build two variants of this library that can live side by
side (so applications can link against the appropriate variation)?

Conceptually, it’s something like this:

driver_sources = [ ... ]
env.Library('drivers', driver_sources)

env.Library('drivers_withflag', driver_sources, 
            CPPDEFINES += ['FLAG'])

SCons (understandably) doesn’t like using the same source list for different
outputs with different environments because the intermediate object names
conflict.

I’m not sure whether to approach this problem by somehow deriving a new
Builder for drivers_withflag objects, or whether I should include my library’s
SConscript twice with some parameter to specify the #defines (and I could put
each variant in its own build directory). Any advice?

  • 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-18T09:29:26+00:00Added an answer on May 18, 2026 at 9:29 am

    Here’s a link to some relevant documentation: http://www.scons.org/doc/1.1.0/HTML/scons-user/x1392.html

    I think it would go something like this

    driver_sources = [ ... ]
    
    env.Library('libdrivers', driver_sources)
    
    env_flag = env.Clone()
    
    env_flag.Append(CPPDEFINES = ['FLAG'])
    
    flag_objects = [os.path.splitext(src)[0] + '_flag' + 
      env['OBJSUFFIX'] for src in driver_sources]
    
    d_wf = [env_flag.Object(tgt, src) for tgt,src in 
      zip(flag_objects, driver_sources)]
    
    env_flag.Library(d_wf)
    

    This would go directly inside your current SConscript file, however you could also take a look at this question: here

    You could use the steps outlined there in whatever file calls your library’s SConscript file to setup two environments, then just call the SConscript twice with each one.

    Hope that helps.

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

Sidebar

Related Questions

I have a C# app for which I've written GDI+ code that uses Bitmap/TextureBrush
hi in my app i a have created an profile page and in that
We have a site that we would like our customers to embed in their
I have setup a simple test project for the EF 4.1 RC, using Code-First
I have a multiplatform application and want to add audio annotations functionality. I am
I ship a public header that users compile against to utilize classes contained within.
I am a very beginner to Java, recently trying to use some existing libraries
I need some help with properly versioning my Android project with Git/Eclipse. I have
One of the most powerful patterns available in Scala is the enrich-my-library* pattern, which
I've been searching for the past 2 days, and while I've found similar questions

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.