Reputation: 394
I am trying to create the simplest imaginable SConstruct file for cross compiling a program. I tried different settings, the latest SConstruct file is here:
env_options = {
"CC" : "arm-linux-gnueabihf-gcc",
"CXX" : "arm-linux-gnueabihf-g++",
"LD" : "arm-linux-gnueabihf-ld",
"AR" : "arm-linux-gnueabihf-ar",
"STRIP" : "arm-linux-gnueabihf-strip"
}
env = Environment(**env_options)
path = ['/path/to/toolchain/bin/']
env.Append( ENV = {'PATH' : path})
p = Program( "prog", [ "prog.c", "mylib.c" ], CFLAGS=[ '-Iinclude', '-Werror', '-Wall', '-Wextra' ] )
The output of env.Dump()
shows e.g.:
{ 'AR': 'arm-linux-gnueabihf-ar',
'CC': 'arm-linux-gnueabihf-gcc',
'CXX': 'arm-linux-gnueabihf-g++',
'ENV': { 'PATH': [ '/path/to/toolchain/bin/']},
'LD': 'arm-linux-gnueabihf-ld',
'TOOLS': [ 'default',
'gnulink',
'gcc',
'g++',
'gas',
'ar',
'filesystem',
'm4',
'zip']
}
I don't see any surprises in the env.Dump()
output (especially no standard system paths), and thought that in case scons can not find the tools listed in env_options
I would at least get an error message.
Instead, scons uses the default tools and builds the program for my host system.
I've considered the answers posted here(1) and here(2) - with no success so far.
arm-linux-gnueabihf-gcc-4.8.3
and there are no system paths like /bin/
or /usr/bin
set in ENV )?Upvotes: 4
Views: 1378
Reputation: 3509
p = Program( "prog", [ "prog.c", "mylib.c" ], CFLAGS=[ '-Iinclude', '-Werror', '-Wall', '-Wextra' ] )
Should be
p = env.Program( "prog", [ "prog.c", "mylib.c" ], CFLAGS=[ '-Iinclude', '-Werror', '-Wall', '-Wextra' ] )
Using Program instead of env.Program uses the default environment which doesn't have CC,etc set to any non-default values.
Upvotes: 2