linking custom modules (dmd)

Jonathan M Davis jmdavisProg at gmx.com
Thu Nov 18 02:59:49 PST 2010


On Thursday 18 November 2010 02:34:39 spir wrote:
> Hello,
> 
> I haven't found the way to have custom modules linked by dmd like stdlib
> ones. For instance, if program P imports modules M and std.string, I need
> to manually write a build command like: $ dmd -w -ofP P.d M.d
> What have I missed?

_All_ modules and libraries that you want to build/link with your program must 
be passed to dmd. That means either explicitly listing them or having them 
listed in the DFLAGS environment variable. dmd.conf sets that variable and 
includes the druntime and phobos libraries in it. dmd does not go searching for 
modules or libraries that you don't actually give it.

It would be nice if it were to be smart enough to go looking at all the 
directories that it's given and grab the appropriate files since the package 
system clearly delineates where the files are (since packages and folders are in 
a one-to-one ratio with identical names), but unfortunately, it doesn't work 
that way. If you want that sort of behavior, you have to use an external tool, 
and I'm not all that familiar with what they are, since I don't use them, and 
some of them don't work with D2.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list