compilation issues (dmd, rdmd, ldc2)

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 21 12:50:11 PST 2016


On Sunday, 21 February 2016 at 20:04:34 UTC, kraxli wrote:
> What is going on here and what is the difference between dmd 
> and rdmd?

dmd compiles the modules that you specify on the command line. By 
default, it then links an executable from the generated object 
files. The linking can only work when you give dmd all the code, 
either in source form or in compiled object form. When something 
is missing, you get "undefined reference" errors.

That means, when your program has multiple source files 
(including libraries), you must put them all on the dmd command 
line. Or you can compile modules individually (without linking, 
-c flag), and then put the generated object files on the command 
line when linking.

rdmd is a wrapper around dmd (or another, compatible compiler). 
It reads the dependency tree of the modules, and runs dmd on all 
of the source files at once. That means, you only need to put the 
root module on the command line for rdmd. rdmd reads the imports 
and generates a full list of source files for dmd.

> Moreover, ldc2 has conflicts with modules which is probably due 
> to installation, linking and scope issues. How can I shrink the 
> scope for ldc2 such that it only looks at the "right place" for 
> modules (and where is that?) ?
>
> $ ldc2 -I~/.dub/packages/consoled-1.0.0/source/  appX.d
> /usr/local/include/d/std/range.d(287): Error: module std.range 
> from file /usr/local/include/d/std/range.d conflicts with 
> package name range

I don't know what's going on there, but there shouldn't be a 
std/range.d with recent versions of phobos. It's a package since 
2.067.0. Maybe a leftover from a previous installation?


More information about the Digitalmars-d-learn mailing list