[Scons-users] Trouble Finding GCC

Mats Wichmann mats at wichmann.us
Mon Sep 16 14:23:00 EDT 2024


On 9/16/24 12:06, Waqar, Faaiq G wrote:
> Thank you for your response, and making me aware of this question from the FAQ.
> So the gcc I am using is located in is /usr/bin/gcc. I added the following lines to my SConscript based my rudimentary understanding of the FAQ solution:
> 
> main = Environment(tools=[
>          'default', 'git', TempFileSpawn, EnvDefaults, MakeActionTool,
>          ConfigFile, AddLocalRPATH, SwitchingHeaders, TagImpliesTool, Blob
>      ])
> 
> ->main.AppendENVPath('PATH', '/usr/bin/gcc')
> ->main.Tool("gcc")
> 
> main.Tool(SCons.Tool.FindTool(['gcc', 'clang'], main))
> main.Tool(SCons.Tool.FindTool(['g++', 'clang++'], main))
> 
> I am still running into the issue, I assume because I am not using this correctly. Any advice? Thank you again for your time
/usr/bin should be part of the default path. The default path on 
POSIX-like systems is:

env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin:/snap/bin'

I think there's possibly a terminology overload here...  the Tool() 
method loads what SCons calls a Tool Specification Module - which does 
setup so that you can go ahead and use the actual underlying program. 
It happens that the tool modules for the binaries named gcc and clang 
use the same names...  but you don't want to pass the path to the 
binary, like /usr/bin/gcc, to Tool, you want SCons to find the tool 
module itself, which will be in a path like 
[path-to-SCons]/SCons/Tool/gcc.py.  (g++ has a tool named gcc and 
clang++ has one named clangxx, because a '+' is not valid in a Python 
module name).

The "public API" for finding a tool is env.Detect() (well, 
main.Detect(), which you shouldn't even have to use, but as an 
experiment you could run:

print(main.Detect(['gcc', 'clang'])

and see if it finds either of those - it just returns the name, not the 
path.




More information about the Scons-users mailing list