Passing directory as compiler argument not finding file

Cym13 cpicard at openmailbox.org
Fri Apr 13 22:37:55 UTC 2018


On Friday, 13 April 2018 at 13:39:23 UTC, Tony wrote:
> On Friday, 13 April 2018 at 12:46:32 UTC, Cym13 wrote:
>> On Friday, 13 April 2018 at 01:27:06 UTC, Tony wrote:
>>> I think that the typical model (at least in other languages) 
>>> is to only compile one D source file at a time. Compile the 
>>> b.d file with the -c option to create an object file. Then 
>>> put the object file in a library file (either static (easier) 
>>> or dynamic). Then you can use the -L compiler option to 
>>> specify the directory of the library and the -l  compiler 
>>> option to specify the library (library name is shortened - 
>>> libb.a referenced as -lb).
>>
>> Regardless of whether that would work or not this is the 
>> opposite of what's recommended in D. D compilers expect you to 
>> compile everything at once, or at least by module. That's 
>> where it works best when it comes to optimizations etc.
>
> What does "or at least by module" mean? Is it possible to have 
> a module that is made up of more than one source file?

Sorry, I really meant "package" here, not module.

> What information does a D compiler get when you stick a.d and 
> b.d on the command line that it doesn't get if you compile a.d 
> and import b.d ?

Hmm. I can't quite remember honnestly. What I do remember is 
Andrei saying times and times again that D supports compilation 
by package and not incremental compilation (which is difficult 
because of CTFE and templates), but on second thought maybe you 
won't run into issues if compiling each module separately as long 
as you compile them all. However I'm pretty sure you'll get worse 
compilation times as the compiler can't make use of symbol cache 
etc. That may be the main reason why people generally avoid 
compiling separately each module and just put every file on the 
command line. AFAIK dmd is designed to be used that way.


More information about the Digitalmars-d-learn mailing list