tags:

views:

293

answers:

3

I have an SConstruct file for scons:

env = Environment()
env.Append(CPPPATH = ['./'])
env.Append(LIBS = 'kernel32.lib')
env.Append(LIBPATH = 'C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib')

env.SharedLibrary(target='warpLib', source='warplib.cpp')

If I don't inlcude 'kernel32.lib' and specifiy the LIBPATH I get a link error. My solution works, but doesn't look very portable ... What is a better, more portable solution?

A: 

Rather than calling scons from a standard command line, use the visual studio command prompt, that will set up all your environment variables correctly

Andrew Walker
+2  A: 

Use SCons declaration 'DefaultEnvironment(ENV=os.environ)'.

afsas
A: 

I prefer to use the following syntax because it reminds me that I am ultimately using Python, and prefer to use the native Python list commands than their pseduo SCons equivalents. Additionally, it helps me remember that CPPATH,LIBS,LIBPATH, etc are all lists.

env = Environment()
env["CPPPATH"].extend(["."])
env["LIBS"].extend(["kernel32","someotherlib"]) #No need to specify the ".lib". This gives you platform-independance automatically.
env["LIBPATH"].extend(["C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib"])
imran.fanaswala