www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compiler import path

reply "John C" <johnch_atms hotmail.com> writes:
I've never been able to get the D compiler to recognise my additions to the 
import path, either in sc.ini or on the command line (via batch files). I've 
searched the newsgroups to no avail. Anyone see what I'm doing wrong? This 
is for Windows XP, by the way.

    dmd -IC:\Projects\test main.d

    dmd -I"C:\Projects\test" main.d

    dmd "-IC:\Projects\test" main.d

All result in this error:
    main.d: module main cannot read file 'main.d'

main.d has a valid module declaration. It compiles if I cd to 
C:\Projects\test first. But I'd like to find out the correct format for the 
import path so I can use multiple libraries, which may be in disparate 
directories.

Thanks. 
Oct 04 2005
parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
The import path is for the files imported by the files you compile. That is
if you import anything non-phobos from main.d, and it lies somewhere else,
you need to provide an importpath.

I think your first format in your post is correct for the import path. Your
problem is that main.d isn't an imported file, and thus you must do this:

dmd C:\Projects\test\main.d

to compile that file.

Lars Ivar Igesund

John C wrote:

 I've never been able to get the D compiler to recognise my additions to
 the import path, either in sc.ini or on the command line (via batch
 files). I've searched the newsgroups to no avail. Anyone see what I'm
 doing wrong? This is for Windows XP, by the way.
 
     dmd -IC:\Projects\test main.d
 
     dmd -I"C:\Projects\test" main.d
 
     dmd "-IC:\Projects\test" main.d
 
 All result in this error:
     main.d: module main cannot read file 'main.d'
 
 main.d has a valid module declaration. It compiles if I cd to
 C:\Projects\test first. But I'd like to find out the correct format for
 the import path so I can use multiple libraries, which may be in disparate
 directories.
 
 Thanks.
Oct 04 2005
parent reply "John C" <johnch_atms hotmail.com> writes:
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message 
news:dhtnl3$13cb$1 digitaldaemon.com...
 The import path is for the files imported by the files you compile. That 
 is
 if you import anything non-phobos from main.d, and it lies somewhere else,
 you need to provide an importpath.

 I think your first format in your post is correct for the import path. 
 Your
 problem is that main.d isn't an imported file, and thus you must do this:

 dmd C:\Projects\test\main.d

 to compile that file.
You're right in this instance, but the problem still stands. If I attempt to import other modules on my import path, the compiler tells me it can't read that module. So this: dmd -IC:\Projects\test C:\Projects\test\main.d example.d fails when example.d is in C:\Projects\test and main imports example.
 Lars Ivar Igesund

 John C wrote:

 I've never been able to get the D compiler to recognise my additions to
 the import path, either in sc.ini or on the command line (via batch
 files). I've searched the newsgroups to no avail. Anyone see what I'm
 doing wrong? This is for Windows XP, by the way.

     dmd -IC:\Projects\test main.d

     dmd -I"C:\Projects\test" main.d

     dmd "-IC:\Projects\test" main.d

 All result in this error:
     main.d: module main cannot read file 'main.d'

 main.d has a valid module declaration. It compiles if I cd to
 C:\Projects\test first. But I'd like to find out the correct format for
 the import path so I can use multiple libraries, which may be in 
 disparate
 directories.

 Thanks.
Oct 04 2005
parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
Yes, but your command line below also compiles example.d. If you want to
only import it in main.d, that is there is no code to be linked in, just
symbols, don't put example.d on the command line at all. If both files must
be compiled and linked in, you must do this

dmd C:\Projects\test\main.d C:\Projects\test\example.d

:)

Lars Ivar Igesund


John C wrote:

 "Lars Ivar Igesund" <larsivar igesund.net> wrote in message
 news:dhtnl3$13cb$1 digitaldaemon.com...
 The import path is for the files imported by the files you compile. That
 is
 if you import anything non-phobos from main.d, and it lies somewhere
 else, you need to provide an importpath.

 I think your first format in your post is correct for the import path.
 Your
 problem is that main.d isn't an imported file, and thus you must do this:

 dmd C:\Projects\test\main.d

 to compile that file.
You're right in this instance, but the problem still stands. If I attempt to import other modules on my import path, the compiler tells me it can't read that module. So this: dmd -IC:\Projects\test C:\Projects\test\main.d example.d fails when example.d is in C:\Projects\test and main imports example.
 Lars Ivar Igesund

 John C wrote:

 I've never been able to get the D compiler to recognise my additions to
 the import path, either in sc.ini or on the command line (via batch
 files). I've searched the newsgroups to no avail. Anyone see what I'm
 doing wrong? This is for Windows XP, by the way.

     dmd -IC:\Projects\test main.d

     dmd -I"C:\Projects\test" main.d

     dmd "-IC:\Projects\test" main.d

 All result in this error:
     main.d: module main cannot read file 'main.d'

 main.d has a valid module declaration. It compiles if I cd to
 C:\Projects\test first. But I'd like to find out the correct format for
 the import path so I can use multiple libraries, which may be in
 disparate
 directories.

 Thanks.
Oct 04 2005
parent reply "John C" <johnch_atms hotmail.com> writes:
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message 
news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want to
 only import it in main.d, that is there is no code to be linked in, just
 symbols, don't put example.d on the command line at all. If both files 
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
 :)

 Lars Ivar Igesund


 John C wrote:

 "Lars Ivar Igesund" <larsivar igesund.net> wrote in message
 news:dhtnl3$13cb$1 digitaldaemon.com...
 The import path is for the files imported by the files you compile. That
 is
 if you import anything non-phobos from main.d, and it lies somewhere
 else, you need to provide an importpath.

 I think your first format in your post is correct for the import path.
 Your
 problem is that main.d isn't an imported file, and thus you must do 
 this:

 dmd C:\Projects\test\main.d

 to compile that file.
You're right in this instance, but the problem still stands. If I attempt to import other modules on my import path, the compiler tells me it can't read that module. So this: dmd -IC:\Projects\test C:\Projects\test\main.d example.d fails when example.d is in C:\Projects\test and main imports example.
 Lars Ivar Igesund

 John C wrote:

 I've never been able to get the D compiler to recognise my additions to
 the import path, either in sc.ini or on the command line (via batch
 files). I've searched the newsgroups to no avail. Anyone see what I'm
 doing wrong? This is for Windows XP, by the way.

     dmd -IC:\Projects\test main.d

     dmd -I"C:\Projects\test" main.d

     dmd "-IC:\Projects\test" main.d

 All result in this error:
     main.d: module main cannot read file 'main.d'

 main.d has a valid module declaration. It compiles if I cd to
 C:\Projects\test first. But I'd like to find out the correct format for
 the import path so I can use multiple libraries, which may be in
 disparate
 directories.

 Thanks.
Oct 04 2005
next sibling parent reply J C Calvarese <technocrat7 gmail.com> writes:
In article <dhtsvk$18c2$1 digitaldaemon.com>, John C says...
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message 
news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want to
 only import it in main.d, that is there is no code to be linked in, just
 symbols, don't put example.d on the command line at all. If both files 
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
Have you tried? c: cd \project\test dmd main.d example.d (This method requires dmd to be in your path, but I think it's worth the effort.) Alternatively, you migtht try using Build (http://www.dsource.org/projects/build/). jcc7
Oct 04 2005
parent reply "John C" <johnch_atms hotmail.com> writes:
"J C Calvarese" <technocrat7 gmail.com> wrote in message 
news:dhttm5$199q$1 digitaldaemon.com...
 In article <dhtsvk$18c2$1 digitaldaemon.com>, John C says...
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message
news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want to
 only import it in main.d, that is there is no code to be linked in, just
 symbols, don't put example.d on the command line at all. If both files
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
Have you tried? c: cd \project\test dmd main.d example.d
Yes, that's what I've been doing till now. But this will only work for files in the current directory. If I've got files elsewhere (say, C:\AnotherProjectFolder), I need to specify the absolute path. What's worse, DMD doesn't seem to like spaces in paths, even if I use quotes, which is so 1994. Anyone know if the various D build tools supports both of these? Also,
 (This method requires dmd to be in your path, but I think it's worth the
 effort.)

 Alternatively, you migtht try using Build
 (http://www.dsource.org/projects/build/).

 jcc7 
Oct 04 2005
next sibling parent reply Derek Parnell <derek psych.ward> writes:
On Tue, 4 Oct 2005 14:06:32 +0100, John C wrote:

 "J C Calvarese" <technocrat7 gmail.com> wrote in message 
 news:dhttm5$199q$1 digitaldaemon.com...
 In article <dhtsvk$18c2$1 digitaldaemon.com>, John C says...
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message
news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want to
 only import it in main.d, that is there is no code to be linked in, just
 symbols, don't put example.d on the command line at all. If both files
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
Have you tried? c: cd \project\test dmd main.d example.d
Yes, that's what I've been doing till now. But this will only work for files in the current directory. If I've got files elsewhere (say, C:\AnotherProjectFolder), I need to specify the absolute path. What's worse, DMD doesn't seem to like spaces in paths, even if I use quotes, which is so 1994.
Actually, the D compiler does support spaces in the path, but the linker doesn't. The net result is you're still screwed. Walter has stated many times that the linker is not going to be updated.
 Anyone know if the various D build tools supports both of these?
If I'm reading you correctly, you want to say (for instance) ... build main.d example.d and the utility will some how know where on your disk(s) that you have stored these files, right? Maybe if you'd accept a compromise ... what if you give the utility a list of potential areas you that these files might exist, kind like a PATH symbol, and it searches through these. Now that feature I can easily put into Build if you want.

I don't know what that is. Can you point me to a specification etc...? -- Derek Parnell Melbourne, Australia 4/10/2005 11:25:48 PM
Oct 04 2005
next sibling parent reply Derek Parnell <derek psych.ward> writes:
On Tue, 4 Oct 2005 23:33:01 +1000, Derek Parnell wrote:



I don't know what that is. Can you point me to a specification etc...?
Don't bother, I found it myself. The Build utility already supports the idea of response files. For example you can have a file called 'xyz.brf' that contains main.d example.d -unittest -w and use it thus ... build xyz You can have as many response file specification on the command line as you like. The '.brf' is the default extention but you can use anything. Build also supports another sort of response file. In this case the run time options are stored in the Build Configuration file and are used primarily for often used combinations of command line switches. For example, your configuration file (build.cfg) might look like this ... CMDLINE=-Iz:\dlibs [dbg] CMDLINE=-unittest --release --inline -g -w -full CMDLINE=-T{Target}_{Group} [prod] CMDLINE=--unittest --debug* --g --w -release -inline -full CMDLINE=-T{Target}_{Group} and you use it thus ... build main.d +dbg in which case, all the CMDLINE options in the unnamed section are used plus the ones in the [dbg] section. The {Target} would get replaced with 'main' because that's the file used on the command line, and {Group} would get replaced with 'dbg' because that's the section that was specified. This would make the string '-Tmain_dbg' appear on the dmd command line. You can mix'n'match the two response file usages on the same command line. To get the debug edition ... build xyz +dbg To get the production edition ... build xyz +prod -- Derek Parnell Melbourne, Australia 4/10/2005 11:45:23 PM
Oct 04 2005
parent "John C" <johnch_atms hotmail.com> writes:
"Derek Parnell" <derek psych.ward> wrote in message 
news:3hz237k6z1f2$.rdgs4wy4oly6.dlg 40tude.net...
 On Tue, 4 Oct 2005 23:33:01 +1000, Derek Parnell wrote:



I don't know what that is. Can you point me to a specification etc...?
Don't bother, I found it myself. The Build utility already supports the idea of response files. For example you can have a file called 'xyz.brf' that contains main.d example.d -unittest -w and use it thus ... build xyz You can have as many response file specification on the command line as you like. The '.brf' is the default extention but you can use anything. Build also supports another sort of response file. In this case the run time options are stored in the Build Configuration file and are used primarily for often used combinations of command line switches. For example, your configuration file (build.cfg) might look like this ... CMDLINE=-Iz:\dlibs [dbg] CMDLINE=-unittest --release --inline -g -w -full CMDLINE=-T{Target}_{Group} [prod] CMDLINE=--unittest --debug* --g --w -release -inline -full CMDLINE=-T{Target}_{Group} and you use it thus ... build main.d +dbg in which case, all the CMDLINE options in the unnamed section are used plus the ones in the [dbg] section. The {Target} would get replaced with 'main' because that's the file used on the command line, and {Group} would get replaced with 'dbg' because that's the section that was specified. This would make the string '-Tmain_dbg' appear on the dmd command line. You can mix'n'match the two response file usages on the same command line. To get the debug edition ... build xyz +dbg To get the production edition ... build xyz +prod -- Derek Parnell Melbourne, Australia 4/10/2005 11:45:23 PM
Sounds like what I'm after. I'll give build a whirl. Cheers.
Oct 04 2005
prev sibling parent "John C" <johnch_atms hotmail.com> writes:
"Derek Parnell" <derek psych.ward> wrote in message 
news:47hs1igvu0zw.wp56t9evi2il.dlg 40tude.net...
 On Tue, 4 Oct 2005 14:06:32 +0100, John C wrote:

 "J C Calvarese" <technocrat7 gmail.com> wrote in message
 news:dhttm5$199q$1 digitaldaemon.com...
 In article <dhtsvk$18c2$1 digitaldaemon.com>, John C says...
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message
news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want 
 to
 only import it in main.d, that is there is no code to be linked in, 
 just
 symbols, don't put example.d on the command line at all. If both files
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
Have you tried? c: cd \project\test dmd main.d example.d
Yes, that's what I've been doing till now. But this will only work for files in the current directory. If I've got files elsewhere (say, C:\AnotherProjectFolder), I need to specify the absolute path. What's worse, DMD doesn't seem to like spaces in paths, even if I use quotes, which is so 1994.
Actually, the D compiler does support spaces in the path, but the linker doesn't. The net result is you're still screwed. Walter has stated many times that the linker is not going to be updated.
Oh dear.
 Anyone know if the various D build tools supports both of these?
If I'm reading you correctly, you want to say (for instance) ... build main.d example.d and the utility will some how know where on your disk(s) that you have stored these files, right? Maybe if you'd accept a compromise ... what if you give the utility a list of potential areas you that these files might exist, kind like a PATH symbol, and it searches through these. Now that feature I can easily put into Build if you want.
I don't expect it to magically read my mind, so I'm willing to specify where the tool should look, but just the once. If -I worked for code files, I'd be happy. So yeah, a switch specifying a path/multiple paths would be desirable. I just don't want to clog up my system environment variables (and have to reboot after every change).

I don't know what that is. Can you point me to a specification etc...?
A response file is simply a file that includes command line options, saving the tedium of typing them out all the time. Similar to a custom sc.ini file. So instead of using dmd main ..\blah\graphics.d ..\blah\ui.d ..\blah\xml.d ..\blah\blah.d -of"debug\program.exe" program.res -op -inline -debug -g -O -L/EXET:NT -L/SU:windows:5 you have a response file called something like build.rsp with those options separated out in a readable format, and on the command line do this: build.exe build.rsp The MSDN documentation is sparse (http://tinyurl.com/bqt39) but should point you in the right direction.
 -- 
 Derek Parnell
 Melbourne, Australia
 4/10/2005 11:25:48 PM 
Oct 04 2005
prev sibling next sibling parent "Charles" <noone nowhere.com> writes:
 What's worse, DMD doesn't seem to like spaces in paths, even if I use
 quotes, which is so 1994.
lol "John C" <johnch_atms hotmail.com> wrote in message news:dhtuos$1a6k$1 digitaldaemon.com...
 "J C Calvarese" <technocrat7 gmail.com> wrote in message
 news:dhttm5$199q$1 digitaldaemon.com...
 In article <dhtsvk$18c2$1 digitaldaemon.com>, John C says...
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message
news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want
to
 only import it in main.d, that is there is no code to be linked in,
just
 symbols, don't put example.d on the command line at all. If both files
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
Have you tried? c: cd \project\test dmd main.d example.d
Yes, that's what I've been doing till now. But this will only work for
files
 in the current directory. If I've got files elsewhere (say,
 C:\AnotherProjectFolder), I need to specify the absolute path.

 What's worse, DMD doesn't seem to like spaces in paths, even if I use
 quotes, which is so 1994.

 Anyone know if the various D build tools supports both of these? Also,


 (This method requires dmd to be in your path, but I think it's worth the
 effort.)

 Alternatively, you migtht try using Build
 (http://www.dsource.org/projects/build/).

 jcc7
Oct 04 2005
prev sibling parent J C Calvarese <technocrat7 gmail.com> writes:
In article <dhtuos$1a6k$1 digitaldaemon.com>, John C says...
"J C Calvarese" <technocrat7 gmail.com> wrote in message 
news:dhttm5$199q$1 digitaldaemon.com...
 In article <dhtsvk$18c2$1 digitaldaemon.com>, John C says...
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message
news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want to
 only import it in main.d, that is there is no code to be linked in, just
 symbols, don't put example.d on the command line at all. If both files
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
Have you tried? c: cd \project\test dmd main.d example.d
Yes, that's what I've been doing till now. But this will only work for files in the current directory. If I've got files elsewhere (say, C:\AnotherProjectFolder), I need to specify the absolute path. What's worse, DMD doesn't seem to like spaces in paths, even if I use quotes, which is so 1994.
I suspect you could use the 8-character equivalents, but that might not be practical. For example, "program files" is usually "progra~1". dmd c:\progra~1\myfile.d instead of dmd "c:\program files\myfile.d" jcc7
Oct 04 2005
prev sibling parent Lars Ivar Igesund <larsivar igesund.net> writes:
Try Derek Parnell's build utility, look at www.dsource.org.

Lars Ivar Igesund


John C wrote:

 "Lars Ivar Igesund" <larsivar igesund.net> wrote in message
 news:dhtrpf$167r$1 digitaldaemon.com...
 Yes, but your command line below also compiles example.d. If you want to
 only import it in main.d, that is there is no code to be linked in, just
 symbols, don't put example.d on the command line at all. If both files
 must
 be compiled and linked in, you must do this

 dmd C:\Projects\test\main.d C:\Projects\test\example.d
Thanks for pointing that out, Lars. I hadn't realised. So, if -I is only appropriate for importing symbols, then I reckon it needs another option to specify where to look for code modules, or allow -I to do that too. My command line is getting ridiculously long... John.
 :)

 Lars Ivar Igesund


 John C wrote:

 "Lars Ivar Igesund" <larsivar igesund.net> wrote in message
 news:dhtnl3$13cb$1 digitaldaemon.com...
 The import path is for the files imported by the files you compile.
 That is
 if you import anything non-phobos from main.d, and it lies somewhere
 else, you need to provide an importpath.

 I think your first format in your post is correct for the import path.
 Your
 problem is that main.d isn't an imported file, and thus you must do
 this:

 dmd C:\Projects\test\main.d

 to compile that file.
You're right in this instance, but the problem still stands. If I attempt to import other modules on my import path, the compiler tells me it can't read that module. So this: dmd -IC:\Projects\test C:\Projects\test\main.d example.d fails when example.d is in C:\Projects\test and main imports example.
 Lars Ivar Igesund

 John C wrote:

 I've never been able to get the D compiler to recognise my additions
 to the import path, either in sc.ini or on the command line (via batch
 files). I've searched the newsgroups to no avail. Anyone see what I'm
 doing wrong? This is for Windows XP, by the way.

     dmd -IC:\Projects\test main.d

     dmd -I"C:\Projects\test" main.d

     dmd "-IC:\Projects\test" main.d

 All result in this error:
     main.d: module main cannot read file 'main.d'

 main.d has a valid module declaration. It compiles if I cd to
 C:\Projects\test first. But I'd like to find out the correct format
 for the import path so I can use multiple libraries, which may be in
 disparate
 directories.

 Thanks.
Oct 04 2005