Please note:The SCons wiki is in read-only mode due to ongoing spam/DoS issues. Also, new account creation is currently disabled. We are looking into alternative wiki hosts.
Differences between revisions 10 and 11
Revision 10 as of 2012-06-28 11:06:12
Size: 1519
Editor: PedroLarroy
Comment: remove outdated and broken link
Revision 11 as of 2012-09-07 09:50:17
Size: 1260
Editor: PedroLarroy
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:
env = Environment(tools = ["default", "gch"], toolpath = '.')

env['Gch'] = env.Gch('myprogramheader.hpp')[0]
program = env.Program('myprogram', 'mysource.cpp')

env['GchSh'] = env.GchSh('mylibraryheader.hpp')[0]
library = env.SharedLibrary('mylib', 'mylib.cpp')

See comments on top of the file

Gch Builder

The Gch Builder provides a similar interface for precompiled headers on gcc like the PCH builder for msvc. Dependencies of shared objects and static objects are autogenerated.


  • different gch's for shared objects and static objects are required, thus there are two builders Gch and GchSh

  • mixing Gch and GchSh for the same header file is not possible, since gcc seems to look only for one gch

    • TIP: GCC supports multiple precompiled headers (with different compiler options) by putting them in a folder named "headername.gch" with different names. The builder could use this to create a pch for each set of options used...

Explanation and additional usage instructions

This way we check if an object file depends on the original header from which precompiled header was generated. To use modified tool with build dirs you modify the build environment in SConscript like this:

   1 env.Prepend(CPPPATH=['.'])

which will ensure that the compiler looks for (precompiled) header in a build dir before the source dir. I'm not sure if this can be automated somehow.

Code in github


See comments on top of the file

GchBuilder (last edited 2012-09-07 09:50:17 by PedroLarroy)