Search code examples
environment-variablessconscross-compilingscratchbox

Scons in Scratchbox: Can't find g++


I've been using sbox with a Make-based codebase with no problems. Now I'm using a scons-based codebase, and am getting some odd problems.

It seems that within scratchbox, scons can't find g++. For example, it attempts to execute things like:

o hello hello.c

When it should be doing:

g++ -o hello hello.c

So presumably its g++ string variable is empty. g++ is present and in the PATH - "which g++" produces /scratchbox/compilers/bin/g++.

The same source builds fine outside of scratchbox, so it shouldn't be a problem with scons or the codebase. There are no special environment variables set outside of scratchbox when it works.

If I symbolically link /usr/bin/g++ to /scratchbox/compilers/bin/g++, it gets a bit further (produces the correct-looking g++ commands) but then upon executing them produces:

sb_gcc_wrapper (g++): /scratchbox/compilers/arm-linux-cs2007q3-51sb3/bin/sbox-arm-none-linux-gnueabi-g++: No such file or directory

The file listed is present.

PATH contains /scratchbox/compilers/bin, SBOX_REDIRECT_FROM_DIRS contains /usr/bin and SBOX_REDIRECT_TO_DIRS contains /scratchbox/compilers/bin, so I think it should be able to find it.

Any suggestions would be appreciated! Thanks, Ray

Edit: Perhaps related - it also can't find pkg-config unless I prepend the full path within the scons file


Solution

  • scons does not propagate the PATH environment variable, so testing e.g. 'which g++' doesn't help much.

    Either set the compilers directly, e.g.
    env['CXX'] = '/scratchbox/compilers/bin/g++'
    

    Build your own explicit PATH

    path = ['/scratchbox/compilers/bin/','/bin', '/usr/bin', '/sbin','/usr/sbin']
    env = Environment(ENV = {'PATH' : path})
    

    Or use the PATH env variable from your shell

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