Novikov Novikov -4 years ago 157
C++ Question

Crossplatform building Boost with SCons

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.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.

Answer Source

You'll need something like:

import os

env = Environment()
boost_prefix = ""
if is_windows:
  boost_prefix = "path_to_boost"
  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 = [...])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download