Scons and dmd error: unrecognized file extension o

467 Views Asked by At

I am trying to build a "hello world" D project with SConstruct and getting this output:

D:\projects\test>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:\Python27\Scripts\scons.py", line 192, in <module>
scons: Building targets ...
dmd -I. -c -ofsrc\main.o src\main.d
dmd -ofhello.exe src\main.o
Error: unrecognized file extension o
scons: *** [hello.exe] Error 1
scons: building terminated because of errors.

Further I discovered that dmd compiler generates object files with the *.obj extension, rather then *.o and it is not able to handle with *.o files.

Is there a way to make SCons to use default output for dmd object files or to pass *.obj files extension for them? Or this is just a bug?

My SConstruct file:

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

My platform is Windows 7 x86_64.

dmd vervion is 2.064.2.

1

There are 1 best solutions below

2
On

You need to tell SCons to use the D compiler, as I dont believe it does so by default. This does more than just load the compiler, it also sets the corresponding Construction Variables, which among other things sets the object file extension that you are asking about.

If you create your environment as follows, then the D compiler and related construction variables will be loaded.

env=Environment(tools=['default', 'dmd'])