www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to handle differrnt modules which has same file name ?

reply z_axis <z_axis 163.com> writes:
For ezample, the directory is as below:
d:\src\p1\a.d
d:\src\p2\a.d

d:\src\test.d

import p1.a;
import p2.a;

void main(char[][] args) {
//...
}


d:\src\dmd -O -release -w -L/SUBSYSTEM:windows:5 test.d p1\a.d p2\a.d

compling is ok however cannot link !!!  because p2.a.obj will overwrite  
p1.a.obj. then there is only one a.obj in d:\src !!!
what is the best way to solve this problem ?


regards!
Nov 20 2007
next sibling parent Regan Heath <regan netmail.co.nz> writes:
z_axis wrote:
 For ezample, the directory is as below:
 d:\src\p1\a.d
 d:\src\p2\a.d
 
 d:\src\test.d
 
 import p1.a;
 import p2.a;
 
 void main(char[][] args) {
 //...
 }
 
 
 d:\src\dmd -O -release -w -L/SUBSYSTEM:windows:5 test.d p1\a.d p2\a.d
 
 compling is ok however cannot link !!!  because p2.a.obj will overwrite 
 p1.a.obj. then there is only one a.obj in d:\src !!!
 what is the best way to solve this problem ?

It seems odd to me that DMD is creating all object files in the execution path. I remember having similar issues with make/cc on certain UNIX os's and having to use special makefile syntax to cause obj files to appear in the same directory as the source. That is essentially what you want to do here, and you can do it by compiling each a.d file seperately, eg. cd \src\p1 dmd -c a.d cd \src\p2 dmd -c a.d cd \src dmd -O -release -w -L/SUBSYSTEM:windows:5 test.d p1\a.obj p2\a.obj You should think about using a build tool like rebuild, bud, etc. I would hope they can handle this sort of situation. Regan
Nov 20 2007
prev sibling next sibling parent Sascha Katzner <sorry.no spam.invalid> writes:
z_axis wrote:
 what is the best way to solve this problem ?

Build them separately in their directories (via -c) and at the end link all together via: dmd -oftest.exe test.obj p1\a.obj p2\a.obj LLAP, Sascha Katzner
Nov 20 2007
prev sibling parent reply JScott <jrs7561 louisiana.edu> writes:
z_axis Wrote:

 For ezample, the directory is as below:
 d:\src\p1\a.d
 d:\src\p2\a.d
 
 d:\src\test.d
 
 import p1.a;
 import p2.a;
 
 void main(char[][] args) {
 //...
 }
 
 
 d:\src\dmd -O -release -w -L/SUBSYSTEM:windows:5 test.d p1\a.d p2\a.d
 
 compling is ok however cannot link !!!  because p2.a.obj will overwrite  
 p1.a.obj. then there is only one a.obj in d:\src !!!
 what is the best way to solve this problem ?
 
 
 regards!

I think you can solve this problem by using the -op option.
Nov 20 2007
parent z_axis <z_axis 163.com> writes:
在 Tue, 20 Nov 2007 21:37:09 +0800,JScott <jrs7561 louisiana.edu> 写道:

 z_axis Wrote:

 For ezample, the directory is as below:
 d:\src\p1\a.d
 d:\src\p2\a.d

 d:\src\test.d

 import p1.a;
 import p2.a;

 void main(char[][] args) {
 //...
 }


 d:\src\dmd -O -release -w -L/SUBSYSTEM:windows:5 test.d p1\a.d p2\a.d

 compling is ok however cannot link !!!  because p2.a.obj will overwrite
 p1.a.obj. then there is only one a.obj in d:\src !!!
 what is the best way to solve this problem ?


 regards!

I think you can solve this problem by using the -op option.

great ! -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Nov 20 2007