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 1078057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:40:08+00:00 2026-05-16T21:40:08+00:00

I have a project which I build using SCons (and MinGW/gcc depending on the

  • 0

I have a project which I build using SCons (and MinGW/gcc depending on the platform). This project depends on several other libraries (lets call them libfoo and libbar) which can be installed on different places for different users.

Currently, my SConstruct file embeds hard-coded path to those libraries (say, something like: C:\libfoo).

Now, I’d like to add a configuration option to my SConstruct file so that a user who installed libfoo at another location (say C:\custom_path\libfoo) can do something like:

> scons --configure --libfoo-prefix=C:\custom_path\libfoo

Or:

> scons --configure
scons: Reading SConscript files ...
scons: done reading SConscript files.
### Environment configuration ###
Please enter location of 'libfoo' ("C:\libfoo"): C:\custom_path\libfoo
Please enter location of 'libbar' ("C:\libfoo"): C:\custom_path\libbar
### Configuration over ###

Once chosen, those configuration options should be written to some file and reread automatically every time scons runs.

Does scons provide such a mechanism ? How would I achieve this behavior ? I don’t exactly master Python so even obvious (but complete) solutions are welcome.

Thanks.

  • 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-16T21:40:08+00:00Added an answer on May 16, 2026 at 9:40 pm

    SCons has a feature called “Variables“. You can set it up so that it reads from command line argument variables pretty easily. So in your case you would do something like this from the command line:

    scons LIBFOO=C:\custom_path\libfoo
    

    … and the variable would be remembered between runs. So next time you just run scons and it uses the previous value of LIBFOO.

    In code you use it like so:

    # read variables from the cache, a user's custom.py file or command line
    # arguments
    var = Variables(['variables.cache', 'custom.py'], ARGUMENTS)
    # add a path variable
    var.AddVariables(PathVariable('LIBFOO',
            'where the foo library is installed',
            r'C:\default\libfoo', PathVariable.PathIsDir))
    
    env = Environment(variables=var)
    env.Program('test', 'main.c', LIBPATH='$LIBFOO')
    
    # save variables to a file
    var.Save('variables.cache', env)
    

    If you really wanted to use “–” style options then you could combine the above with the AddOption function, but it is more complicated.

    This SO question talks about the issues involved in getting values out of the Variables object without passing them through an Environment.

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

Sidebar

Related Questions

I'm using a MinGW-based GCC cross-compiler to compile a project which uses SCons as
I have a project which I can build and deploy correctly using Ant I
I have a Rails project which I neglected to build tests for (for shame!)
I have inherited a visual studio 2003 project which uses some custom build steps.
I have a C# project in VS2008 which I wish to build for two
I have a CC.NET project configured to call a common NAnt build file, which
Our project is held in a SourceSafe database. We have an automated build, which
I have a project which is source controlled using Subversion and VisualSVN. Since the
I have a C++ project which is using boost. The whole project is built
I have been using cmake to build my projects out of source, which is

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.