Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCons can't pick the compiler (MinGW) [duplicate]

Tags:

c++

scons

I have a simple SConstruct file with the following code

path = ['C:\\MinGW\\bin']
env = Environment(ENV = {'PATH' : path})

Program(target = 'myprogram', source = ['main.cpp'])

running 'scons' on cmd gives the following error message:

cl /Fomain.obj /c main.cpp /TP /nologo
'cl' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [main.obj] Error 1
scons: building terminated because of errors.

It looks like SCons does not pick my compiler (MinGW). What am I doing wrong? I'm on Windows 7 64bit.

like image 881
Amani Avatar asked Mar 20 '23 21:03

Amani


2 Answers

After setting tools variable in environment you should use env.Program('...') instead of Program('...'). Below is my working SConstruct for mingw:

path = ['C:\\Dev\\MinGW\\x64-4.9.2-posix-seh-rt_v3-rev1\\mingw64\\bin']
temp = 'C:\\Temp'

env = Environment(ENV={'PATH': path, 'TEMP': temp}, 
                  tools=['mingw'])

env.Program('solver-tikhonov.cpp')
like image 180
Alec Kalinin Avatar answered Mar 23 '23 09:03

Alec Kalinin


SCons is trying to build with the default Windows tools, namely cl, which is the visual studio compiler. You need to tell it to use the mingw toolset, as follows:

path = ['C:\\MinGW\\bin']
env = Environment(tools=['mingw'], ENV = {'PATH' : path})

After doing this, if it still cant find the mingw compiler, you can set it as follows:

env.Replace(CC='path/to/mingw/cc/compiler',
            CXX='path/to/mingw/c++/compiler')
like image 35
Brady Avatar answered Mar 23 '23 11:03

Brady