c – SCons无法选择编译器(MinGW)
作者:互联网
参见英文答案 > How to tell scons to use MinGW instead of MSVC 2个
我有一个简单的SConstruct文件,其中包含以下代码
path = ['C:\\MinGW\\bin']
env = Environment(ENV = {'PATH' : path})
Program(target = 'myprogram', source = ['main.cpp'])
在cmd上运行’scons’会出现以下错误消息:
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.
看起来SCons不会选择我的编译器(MinGW).我究竟做错了什么?
我在Windows 7 64bit上.
解决方法:
在环境中设置工具变量后,您应该使用env.Program(‘…’)而不是Program(‘…’).以下是我为mingw工作的SConstruct:
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')