How to point scons to a different compiler installed in my home directory?

一笑奈何 提交于 2019-12-23 20:12:44

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!