Scons和dmd错误:无法识别的文件扩展名o



我正试图用SConstruct构建一个"你好世界"D项目,并获得以下输出:

D:projectstest>scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:Python27Scriptsscons.py", line 192, in <module>
scons: Building targets ...
dmd -I. -c -ofsrcmain.o srcmain.d
dmd -ofhello.exe srcmain.o
Error: unrecognized file extension o
scons: *** [hello.exe] Error 1
scons: building terminated because of errors.

此外,我发现dmd编译器生成的对象文件扩展名为*.obj,而不是*.o,并且它无法处理*.o文件。

有没有办法让SCons使用dmd对象文件的默认输出,或者为它们传递*.obj文件扩展名?或者这只是一个bug?

我的SConstruct文件:

import os
env = Environment(ENV=os.environ)
env.Object(target = 'hello', source = 'src/main.d')

我的平台是Windows 7 x86_64。

dmd-vervion为2.064.2。

您需要告诉SCons使用D编译器,因为我认为默认情况下不会这样做。这不仅仅是加载编译器,它还设置了相应的构造变量,其中包括设置您所询问的对象文件扩展名。

如果按照以下方式创建环境,则将加载D编译器和相关的构造变量。

env=环境(tools=["默认","dmd"])

最新更新