SCons is a build system.

The logo for the SCons build system.


Ubuntu 16.04

You can install scons with:


The default scons provided by 16.04 (xenial) is very out-of-date (v2.4.1). You can get the latest scons (v3.0.1) as of Mar 2018) by first adding the following line to /etc/apt/sources.list:

And then install scons with the command:

Basic Hello, World Example


  • scons is installed on your system

NOTE: The console commands assume a UNIX-style terminal, although the example should be easily doable on any OS supported by scons.


  1. Create a new folder called “HelloProject”. All following files in this example will be created in this folder.
  2. Create a file called main.cpp with the following content:
  3. Create a file called sconstruct (no file extension) with the following content:
  4. From the console, run scons in the current folder:
  5. This should start the build process and produce an executable called hello. Run the executable with the following command:
  6. Finished!

Importing And Exporting

scons variables may be shared between sconscript files through importingexporting and returning.

Before you can import a variable, it must be exported. You can do this by calling Export() and providing it with a space-separated string of all the variables you wish to export:

You can then import this from a different Sconscript file:

You can return a single object from a Sconscript with the Return() function:

The can be captured in the calling Sconscript file with:



By default, scons does not perform an out-of-source build. You can perform an out-of-source build by including the following line in your root-level sconstruct file:

where src/MyApp.scons points to a child scons file.

Posted: March 15th, 2018 at 9:02 am
Last Updated on: March 17th, 2018 at 5:45 am