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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:36:08+00:00 2026-06-04T11:36:08+00:00

I have the following SCons configuration: current_directory |-<.cpp files> |-<.h files> |-SConstruct |-SConscript |-bin

  • 0

I have the following SCons configuration:

current_directory
|-<.cpp files>
|-<.h files>
|-SConstruct
|-SConscript
|-bin
  |-<empty>

I want to build my source files and put the executable and the object files into the bin directory.

This is what I have in my SConstruct file:

SConscript('SConscript', variant_dir='bin', duplicate=0)

While in the SConsript file I have:

debug_environment.Program(target = 'SsaTest', src_files, LIBS=libraries, LIBPATH=libraries_path)

When I build using scons command I get the SsaTest executable in the bin directory (as desired), but the object files are left in the current directory.

How can I have the .o files be built in the bin directory as well?

Many thanks.

EDIT: Complete SConscript file (forgive me for the xxxs)

import os

# This is correctly Exported()
Import('debug_flags')

# Paths to header files
headers_paths = ['#/../../xxx/include/',
                 '#/../../../xxx/include/',
                 '#/../../xxx/include/',
                 '#/../../xxx/include/',
                 '#/../../xxx/include/']

# Path to source files
src_folder = '#./'

# Source files list
src_files = ['xxx.cpp',
             'xxx.cpp',
             'xxx.cpp',
             'xxx.cpp',
             'xxx.cpp']

# Prepend the relative path to each source file name
src_files = [src_folder + filename for filename in src_files]

libraries = ['xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx']

libraries_path = ['#/../../xxx/lib',
                  '#/../../../xxx/bin', 
                  '#/../lib', 
                  '#/../../xxx/lib', 
                  '#/../../xxx/lib', 
                  '#/../../xxx/lib']

# Debug environment
debug_environment = Environment(CC = 'g++', CCFLAGS=debug_flags, ENV = os.environ, CPPPATH=headers_paths); 
# Executable build command
debug_environment.Program(target = 'SsaTest', src_files, LIBS=libraries, LIBPATH=libraries_path)
  • 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-06-04T11:36:10+00:00Added an answer on June 4, 2026 at 11:36 am

    Using ‘#’ with source files not recommended, because you have your situation, scons can’t correctly process it with variant dirs and how result create object files in directory where sources placed.

    So, i tryed to build your example with same configuration and have no troubles:

    #SConsctruct
    SConscript('SConscript', variant_dir='bin', duplicate=0)
    
    #SConscript
    src_files = Glob('*.cpp')
    debug_environment = Environment()
    debug_environment.Program('SsaTest', src_files)
    

    So, all object files are generated in bin directory.

    Finally, you have no troubles with relation dirs with sources files then using variant dirs. But include dirs are depended from variant dirs.
    Configuration for example :

    build
    app
    --SConscript
    --src
    ----*.h
    ----*.cpp
    SConstruct
    
    #SConstruct
    rootEnv = Environment()
    Export('rootEnv')
    SConscript('app/SConscript', variant_dir='build', duplicate=0)
    

    You SConscript will be looking like it:

    Import('rootEnv')
    env = rootEnv.Clone()
    env.Append(CPPPATH = ['#app/src'])
    env.Program('app', Glob('src/*.cpp'))
    

    ‘#app/src’ – where # is very important when using variant dir, because if would be app/src, build command will be looking: ‘-Ibuild/app/src’ (adding variant dir before include path). But adding ‘#’ command will be looking correctly : ‘-Iapp/src’.

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

Sidebar

Related Questions

In my SConscript I have the following line: Program(xtest, Split(main.cpp), LIBS=mylib fltk Xft Xinerama
I have the following SConscript file: Java(target='classes', source='.'); Jar(target='test.jar', source='classes') The problem is that
I have following batch file code: @echo off SET INSTALL_PATH=c:\program files\ :ask_again if exist
I am moving Code::Blocks projects to SCons. I have a source tree with the
I have a library, libfoo which is made of the following files: base.hpp #ifndef
I want to drop a database. I have used the following code, but to
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,

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.