First, download ZIP-archive with D compiler. Then unpack it into... for example c:/dmd2. You need directories:
html and man (documentation), samples, src (for including), windows (binary, libraries) and README.TXT. Create somewhere test file, for example a.d:
import std.stdio;
int main(string[] args) {
int[string] d;
d["qwe"] = 12;
d["asd"] = 13;
d["zxc"] = 14;
writef("%d\n", d["asd"]);
int i = 10;
typeof(i) j = 90;
writef("%d", j);
return 0;
}
Then create dmd.conf file (or sc.ini) with next content:
[Environment]
LIB="c:\dmd2\windows\lib"
DFLAGS="-Ic:\dmd2\src\phobos" "-Ic:\dmd2\src\druntime\import"
LINKCMD="c:\dmd2\windows\bin\link"
DDOCFILE=mysettings.ddoc
Now create Makefile:
DBIN=c:/dmd2/windows/bin
LINK=$(DBIN)/link
DMD=$(DBIN)/dmd
RM=rm -rf
DFLAGS=
LFLAGS=
SRC=a.d
OBJS=$(SRC:.d=.o)
EXES=$(SRC:.d=.exe)
.SUFFIXES: .d
.d.o:
$(DMD) $(DFLAGS) -c $< -of$@
clean:
$(RM) $(OBJS) $(EXES)
######################################################################
a: a.o
$(LINK) $(LFLAGS) $<
Now you can compile first D program:
make a
and run it:
a.exe
13
90
Комментариев нет:
Отправить комментарий
Thanks for your posting!