Difficulty: Intermediate
Estimated Time: 10 minutes

This scenario takes you through the basics of using SCons as a build tool for your C/C++ application.

For more details see SCons V3.0.1 Docs

You will learn the following

  1. Setting Up and Testing SCons (on Ubuntu)
  2. Writing your application
  3. Building your application against SCons
  4. Profit

Building with SCons

Step 1 of 4

Step 1 - Setting Up

Setting Up SCons

We'll first download SCons v3.0.1
wget http://prdownloads.sourceforge.net/scons/scons-3.0.1.tar.gz

Then unzip the downloaded artifact into any directory tar -xzf scons-3.0.1.tar.gz

Then we'll install SCons using the following Python command cd scons-3.0.1 && python setup.py install

Let check if everything is working as expected by creating a simple application cd .. && scons -v

mkdir -p helloscons && cd helloscons

Create a simple HelloWorld app in file called app.c

touch app.c

Then add SCons config file

touch SConstruct

Then open the file under helloscons/app.c and paste the following

#include <stdio.h> 
int main() {
    printf("Hello Scons\n");

Also open the file helloscons/SConstruct and paste the following


Let's build


And execute ./app

Let's clean that up now that we're sure SCons is working
cd .. && rm -fr helloscons

Close all open editors and move to the next exercise