clinuxcentossconsdevtoolset

scons still failed after setup env


I am using scons 1.2 on Centos 5, with devtoolset-1.1, devtoolset-1.1 root path locate at /opt/centoss/devtoolset-1.1/. I added devtoolset binary path to PATH variable, this is what I have

[secmask@localhost scons-lab]$ echo $PATH
/usr/kerberos/bin:/opt/centos/devtoolset-1.1/root/usr/bin/:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/secmask/bin
[secmask@localhost scons-lab]$ which gcc
/opt/centos/devtoolset-1.1/root/usr/bin/gcc
[secmask@localhost scons-lab]$ gcc --version
gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
Copyright (C) 2012 Free Software Foundation, Inc.

everything look good, then I try to make a simple C program using scons

int main(){
    printf("OK");
}

I follow the guide at http://www.scons.org/doc/1.2.0/HTML/scons-user/x1673.html setup the env to use os.environ PATH like this, cat SConstruct

import os
env = Environment(ENV = {'PATH' : os.environ['PATH']})
Program('hello.c')

but scons still did not reach gcc

[secmask@localhost scons-lab]$ scons --debug=presub
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Building hello.o with action:
  $CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES
gcc -o hello.o -c hello.c
sh: gcc: command not found
scons: *** [hello.o] Error 127
scons: building terminated because of errors.

so, what I should do now?


Solution

  • After I read some chapters of scons user guide, I realized that I should change Program('hello.c') to env.Program('hello.c') , that will apply new Execution Environment.