Argh! So simple, but it's been driving me crazy for the past two days. Thank you.
"Frits van Bommel" <[email protected]> wrote in message news:[email protected]... > MikeWh wrote: >> I have 2 files: 1. a main file called caller.d, 2. a file to import >> called sub.d. They are: >> >> // caller.d >> import sub; >> import std.stdio; >> void main(){ >> sub mySub= new sub; >> writefln( mySub.one() ); >> } >> >> // sub.d >> class sub{ >> int one(){ >> return 1; >> } >> } >> >> Everything compiles fine using "dmd caller.d sub.d", and correctly writes >> "1" when I execute "caller". >> But if I try "dmd -run caller.d sub.d" I get "OPTLINK Error 42: Symbol >> Undefined _D3sub3sub7_ClassZ" >> I get the error even if I first do "dmd -lib sub.d". Same thing happens >> in D 1.043 as D 2.028. >> >> Anyone know what I'm doing wrong here? > > You can only specify one source file after -run. The rest of the command > line is used as the command line for the program being run. Since sub.d > isn't compiled and linked in, you get the undefined symbol before it gets > that far. > What you want to use is "dmd sub.d -run caller.d".
