问题
I have tried editing SConstruct to point to a different gcc compiler but it always seems to use the one defined in /usr/bin/gcc and /usr/bin/g++.
env = DefaultEnvironment()
env['CC'] = '/home/aaron/devel/bin/gcc'
env['CXX'] = '/home/aaron/devel/bin/g++'
What am I doing wrong? Also, is there a way to specify a different compiler on the command line using something like:
scons cxx=/home/aaron/devel/bin/g++
I've gone crazy trying to make this work. Thanks!
回答1:
There is a suggestion in "Why doesn't SCons find my compiler/linker/etc.?" in the SCons wiki? For your case, that would be
path = ['/path/to/other/compiler/bin', '/bin', '/usr/bin',]
env = Environment(ENV = {'PATH' : path})
i.e., make your own environment with exactly the content you want, such as the $PATH
(other bits of useful advice about environments are close by in the same wiki page).
To add your own options to scons' command line, per the docs, you should be able to use AddOption
, see section 12.1.5 (but, I have not tried this one myself).
回答2:
A "dirty trick" is "just" to make a symbolic link to the new interpretor in the folder where you issue the scons command
来源:https://stackoverflow.com/questions/3304095/how-to-point-scons-to-a-different-compiler-installed-in-my-home-directory