Archiwa tagu: scons

Installing and running SCons on Windows with MinGW

1. Installing Python 2.x 32bit

Right now, when SCons  2.3.4 is the latest available version, it won’t work with python >= 3.4.1. Thats because of modified behavior of print function. Its usage without ( ) is depracted and causes errors in latest python version. This construction is still used in some of SCons scripts.

SCons installer is also not capable of finding installation of 64 bit python.

Thats why you should choose latest ‚2’ version in 32 bit. For me – 2.7.9

For purposes of this test I put Python in default directory:


2. Installing SCons

The easiest way to install SCons on windows is to use default Win32 installer. There are no sophisticated install options.

Installer will put some files in <Python>\Scripts directory. Nothing more, nothing less.

Main SCons executable is wrapped with scons.bat which should be used as default SCons launcher.

3. Creating SCons launcher in projects directory

In your project directory in which your SConstruct file is located you should create new batch file. For purposes of this tutorial I called it ‚run_scons.bat’.

Inside put something like:

if NOT ["%errorlevel%"]==["0"] pause

This will simply run scons.bat in SCons installation directory and pause closing of command line dialog if error occurred.

Creating shortcut to scons.bat won’t work since shortcut changes working directory of environment to targets directory. We want to stay in projects directory.

 4. Configuring SCons to use MinGW instead of MSVC++

Some steps must be done in SConstruct to properly use MinGW compiler

  1. Environment must be initialized with tools = [‚mingw’] parameter
  2. Environment[‚ENV’][‚PATH’] must have „bin” directory of MinGW
  3. Target should be linked with -static option enabled

for example:

E = Environment(tools = ['mingw'])
E['ENV']['PATH'] += ';' + r'C:\Program Files (x86)\mingw-w64\i686-4.9.2-posix-dwarf-rt_v3-rev1\mingw32\bin'
E.Append(LINKFLAGS = "-static")

5. Running SCons

Just double-click run_scons.bat 🙂