Hi. I am trying to write my first D program, and am quite stuck in several
areas. This is on Ubuntu 10.10 with the dmd DMD64 D Compiler v2.055.

[...]

However, none of this stuff works. Here's what I get:
dmd prd.d -unittest
prd.o:(.data+0x250): undefined reference to `_D5Array12__ModuleInfoZ'
prd.o:(.data._D23TypeInfo_S5Array6Parray6__initZ+0x28): undefined reference to
`_D5Array6Parray6__initZ'
prd.o: In function `_D3prd4iotaFiZPS5Array6Parray':
prd.d:(.text._D3prd4iotaFiZPS5Array6Parray+0x101): undefined reference to
`_D5Array6Parray6__ctorMFNcAiAiZS5Array6Parray'
collect2: ld returned 1 exit status
--- errorlevel 1
This is not exactly illuminating, and I have no idea what sort of dumb
mistake(s) I'm making in the code.

[...]
Is Parray defined in another module? If so, you need to include it on
your commandline:
dmd prd.d parray.d -unittest
T
--
There are four kinds of lies: lies, damn lies, and statistics.

The important mangled message here is:
prd.o:(.data+0x250): undefined reference to
`_D5Array12__ModuleInfoZ'
This is a linker error, your code compiled fine. The English
translation:
"There is an undefined reference to module Array"
You are compiling without including all files you need
dmd prd.d Array.d -unittest
That should at least get you to the next error. Also name your
modules with lowercase, this isn't required but is a suggestion.

In the interest of saving you some trouble later on, I thought I'd
explain why the import statement doesn't automatically "bring in" the
referenced file.
When you compile, you need to give DMD the names of all the files which
need to be turned into object code (thus you must specify "Array.d" on
the command line). This is in contrast to linking your code against
already-compiled stuff (the std library is a good example), which you do
not need to provide for compilation. DMD is quietly passing the std
library object file to the linker which is why you don't get linker
errors.
If you want your Array code to be a separate library/project, you can
compile it like so:
dmd Array.d -lib
Then when you compile your other project:
dmd prd.d -I/location/of/Array.d -L/location/of/Array.so
Note that some automated build tools can parse your import statements and
figure out what files need to be included in the dmd command.
Justin

If you want your Array code to be a separate library/project,
you can compile it like so:
dmd Array.d -lib
Then when you compile your other project:
dmd prd.d -I/location/of/Array.d -L/location/of/Array.so
Justin

It is actually a little more than that.
dmd array.d -lib -oflibarray.a
dmd does no currently generate shared libraries, so .a (archive)
is used.
dmd prd.d -I. -L-L. -L-larray
-I (Include directory, used by compiler for locating "header"
files. These are used by the compiler to verify the calls you are
making into the library, and to generate code from templates if
those are being used)
-L-L (Pass to the linker the flag -L. The ld linker flag -L is
for the library search path)
-L-l (Pass the linker the flag -l. The ld linker flag -l request
that a library be linked)
Libraries are named starting with lib by Unix convention. When
passing the library name this is left off (-lm load libm.so or
libm.a). I believe you can leave it on though (-llibm) but am not
sure.
The reason DMD does not compile imported libraries is because of
two reasons. When the magic stops working you still have to deal
with and understand these steps. The compiler is busy with its
job of converting code, it should be helping other tools to make
its job simple ("Compiler as a Service"). You will find rdmd is
distributed with dmd:
rdmd prd.d