views:

54

answers:

1

I tried hard but couldn't find an example of using SCons (or any build system for that matter) to build on both gcc and mvc++ with boost libraries.

Currently my SConstruct looks like

env = Environment()
env.Object(Glob('*.cpp'))
env.Program(target='test', source=Glob('*.o'), LIBS=['boost_filesystem-mt', 'boost_system-mt', 'boost_program_options-mt'])

Which works on Linux but doesn't with Visual C++ which starting with 2010 doesn't let you specify global include directories.

A: 

You'll need something like:

import os

env = Environment()
boost_prefix = ""
if is_windows:
  boost_prefix = "path_to_boost"
else:
  boost_prefix = "/usr" # or wherever you installed boost
sources = env.Glob("*.cpp")
env.Append(CPPPATH = [os.path.join(boost_prefix, "include")])
env.Append(LIBPATH = [os.path.join(boost_prefix, "lib")]
app = env.Program(target = "test", source = sources, LIBS = [...])
env.Default(app)
Tareq A. Siraj
I see, I thought SCons had a more elegant solution to this problem, but I guess it can only do so much. What's annoying is that MSVC++ will automatically link dependencies, but windows has no pkg-config. I'm not sure which is worse gcc toolchain needing explicit linking directives or vc++ needing explicit library paths.
Novikov