www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dmd vs rdmd

--0015177407d0e8eb5e04a56240bc
Content-Type: text/plain; charset=ISO-8859-1

Hello,

I am trying to compile code which is composed of two modules (in the same
directory):

main.d
foo.d

foo.d just declares a class Foo which has a string variable "bar" which i
set to "hello" and main.d just prints bar's value to the console:

// --------- main.d -----------
import std.stdio, foo;

void main() {
    Foo f = new Foo;
    writeln(f.bar);
}

When i attempt to compile main.d via:
$dmd main.d
I get undefined symbol errors.

But when I run:
$rdmd main.d
it works as expected.

The only way I could get main.d to compile with just dmd was to compile foo
as a lib first and then compile main.d and passing the foo.a file as an
argument:
$dmd -lib foo.d
$dmd main.d foo.a

Is this normal?
I got the impression from TDPL (Alexandrescu) that the dmd compiler would
automatically search the root directory, find foo.d, work its magic, and
create all the symbols that were defined in foo.d for main.d to compile...

Thanks,
Josh

--0015177407d0e8eb5e04a56240bc
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,<div><br></div><div>I am trying to compile code which is composed of =
two modules (in the same directory):</div><div><br></div><div>main.d=A0</di=
v><div>foo.d</div><div><br></div><div>foo.d just declares a class Foo which=
 has a string variable &quot;bar&quot; which i set to &quot;hello&quot; and=
 main.d just prints bar&#39;s value to the console:</div>
<div><br></div><div>// --------- main.d -----------</div><div>import std.st=
dio, foo;</div><div><br></div><div>void main() {</div><div>=A0 =A0 Foo f =
=3D new Foo;</div><div>=A0 =A0 writeln(f.bar);</div><div>}</div><div><br></=
div><div>
When i attempt to compile main.d via:=A0</div><div>$dmd main.d=A0</div><div=
I get undefined symbol errors.=A0</div><div><br></div><div>But when I run:=

div> <div>The only way I could get main.d to compile with just dmd was to compil= e foo as a lib first and then compile main.d and passing the foo.a file as = an argument:</div><div>$dmd -lib foo.d</div><div>$dmd main.d foo.a</div> <div><br></div><div>Is this normal? =A0</div><div>I got the impression from= TDPL (Alexandrescu) that the dmd compiler would automatically search the r= oot directory, find foo.d, work its magic, and create all the symbols that = were defined in foo.d for main.d to compile...</div> <div><br></div><div>Thanks,</div><div>Josh</div><div><br></div> --0015177407d0e8eb5e04a56240bc--
Jun 10 2011