SCons- *** No SConstruct file found

user2439278 picture user2439278 · Jun 19, 2013 · Viewed 26k times · Source

Installed SCons using # cd scons-2.3.0 # python setup.py install

After Installation, when i try to run scons , got the below error.

scons: * No SConstruct file found. File "/usr/local/lib/scons-2.3.0/SCons/Script/Main.py", line 905, in _main

How to overcome this ???

Answer

Brady picture Brady · Jun 19, 2013

There are 3 ways to specify the SConstruct file when using SCons, as follows:

  • Execute scons from the root of the project, where there should be a SConstruct file. This is the most standard way.

  • From a subdirectory of the project, where there should be a SConsctruct file at the root, execute scons with one of the following options (as seen by scons -h) to tell it to look up the directory structure for the SConstruct

-u, --up, --search-up
Search up directory tree for SConstruct, build targets at or 
below current directory.

-U
Search up directory tree for SConstruct, build Default() targets 
from local SConscript.
  • Explicitly specify where the SConstruct file is, this is also available from scons -h
-f FILE, --file=FILE, --makefile=FILE, --sconstruct=FILE
Read FILE as the top-level SConstruct file.

Here is an example project in the directory /home/notroot/projectDir with the following directory structure:

SConstruct
subdir/file.hh
subdir/file.cc

Here is how to use the different options mentioned above:

Option 1:

Execute scons from the root project directory

# cd /home/notroot/projectDir
# scons

Option 2:

Execute scons from within the project directory and tell it to look up the dir hierarchy for the SConstruct

# cd /home/notroot/projectDir/subdir
# scons -u

Option 3:

Execute scons from within the project directory and specify the path of the SConstruct

# cd /home/notroot/projectDir/subdir
# scons -f /home/notroot/projectDir/SConstruct