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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:26:31+00:00 2026-06-02T22:26:31+00:00

I have a Hierarchical project that uses source code from a common system-directory, for

  • 0

I have a Hierarchical project that uses source code from a common system-directory, for which I am using the SCons Repository() function and want all the build output (local code and code taken from the Repository) placed in a variant_dir.

If I use the Repository() function in a simple scenario (non-hierchical with no calls to sub-directory SConscripts) then the compiled Repository() object file is placed in the variant_dir as expected. But if I do the same in a hierarchical build, the compiled Repository() object file is placed in the project root directory.

Assuming I want to use the following source code located in a system-directory:

/usr/local/repoDir/repoFile.cc

And I have the following project structure:

# tree .
.
|-- SConstruct
|-- build
|   `-- linux_x86_64
`-- moduleA
    |-- localFile.cc
    `-- SConscript

Here are the build scripts:

SConstruct

Edit: Removed filename from call to Repository(), thanks to Dirk Baechle from users@scons.tigris.org for pointing that out.

env = Environment()

env.Repository('/usr/local/repoDir')

env['variantDir'] = 'build/linux_x86_64'

SConscript('moduleA/SConscript',
           exports = ['env'],
           variant_dir = env['variantDir'],
           duplicate = 0)

moduleA/SConscript

import os

Import('env')

srcFiles = [
  'localFile.cc',
  #os.path.join(env['variantDir'], 'repoFile.cc'),          # fails to find source file
  #'#%s' % os.path.join(env['variantDir'], 'repoFile.cc'),  # fails to find source file
  #'repoFile.cc',                                           # fails to find source file
  '#repoFile.cc',  # only option that works, but places object in root proj dir
]

env.Append(CPPPATH = ['.', '#'])
env.Program(target = 'myApp', source = srcFiles)

I would like the repoFile.cc file to be compiled and have its object file placed in build/linux_x86_64, but instead its placed in the same directory as the root SConstruct.

As you can see from the comments in moduleA/SConscript, I tried referencing the repoFile.cc several different ways, and the only way that worked is as mentioned therein. Additionally, I tried calling the Repository() function in moduleA/SConscript, but it didnt change anything.

Edit: Here is the compilation output

# scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o repoFile.o -c -Ibuild/linux_x86_64 -ImoduleA -I/usr/local/repoDir/moduleA -I/usr/local/repoDir/build/linux_x86_64 -I. -I/usr/local/repoDir /usr/local/repoDir/repoFile.cc
g++ -o build/linux_x86_64/localFile.o -c -Ibuild/linux_x86_64 -ImoduleA -I/usr/local/repoDir/moduleA -I/usr/local/repoDir/build/linux_x86_64 -I. -I/usr/local/repoDir moduleA/localFile.cpp
g++ -o build/linux_x86_64/myApp build/linux_x86_64/localFile.o repoFile.o
scons: done building targets.

And resulting directory structure:

# tree .
.
|-- repoFile.o    <=== This file should be in build/linux_x86_64 NOT here
|-- SConstruct
|-- build
|   `-- linux_x86_64
|       |-- localFile.o
|       `-- myApp
`-- moduleA
    |-- localFile.cpp
    `-- SConscript

I checked around and found this, but its not quite the same:

Scons Hierarchical Builds with Repository directory

Any suggestions as to how I can get the object file in the right place?

  • 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-02T22:26:33+00:00Added an answer on June 2, 2026 at 10:26 pm

    I asked this same question on the SCons-users mailing list, and received some information that partly answers this question. Thanks to Dirk Baechle for helping me with this issue.

    The Repository() function effectively mounts the directory passed in to the root of the SCons project: that is to the directory where the SConstruct file is. If files in a repo sub-directory need to be referenced in sub-directories of the SCons project, then the sub-directory names (that of the repo dir and scons project dir) must match. That’s why the different options in the SConscript file in the question above fail to find the repo file.

    If the repo sub-directory moduleA existed with the file repoFile.cc, then it would be found as expected and the compiled object would be placed in the variant_dir as expected.

    One limitation I see to the Repository() function is that you can’t mount the repo directory to a SCons project sub-directory. This sounds like a feature request.

    The fact that SCons places the compiled object file in the source directory seems like a bug to me. At the very least, it should be placed in the variant_dir root directory.

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

Sidebar

Related Questions

I have a hierarchical maven project, from which I am trying to build a
I'm working on a project where I have some hierarchical data that I want
I have this project that displays hierarchical data with huge amounts of text, and
I have hierarchical data stored in the datastore using a model which looks like
I have a collection of HTML elements that is structured and hierarchical. When an
The following scenario came up in our project: We have hierarchical business objects. The
i have a table with hierarchical structure. like this: (source: aspalliance.com ) and table
From what I understand of subversion if you have a repo that contains multiple
Problem: I have a large Visual C++ project that I'm trying to migrate to
I have a git repository that's used only to hold graphics and sound files

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.