digitalmars.D.learn - -run with import gives OPTLINK Error 42
- MikeWh (22/22) May 16 2009 I have 2 files: 1. a main file called caller.d, 2. a file to import call...
- Frits van Bommel (5/31) May 16 2009 You can only specify one source file after -run. The rest of the command...
- MikeWh (4/36) May 16 2009 Argh! So simple, but it's been driving me crazy for the past two days.
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?
May 16 2009
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".
May 16 2009
Argh! So simple, but it's been driving me crazy for the past two days. Thank you. "Frits van Bommel" <fvbommel REMwOVExCAPSs.nl> wrote in message news:guni54$2r4s$1 digitalmars.com...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".
May 16 2009