www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Static library building

reply Vindex <vindex9 gmail.com> writes:
'main.d':

import pack.mod;
void main() {
     fn("Hello");
}

'mod.d':

module pack.mod;
void fn(string s) {
     import std.stdio;
     writeln("Hello");
}

Both files are in the same directory.
So all is well:
dmd main.d mod.d

So all is bad:
dmd mod.d -lib
dmd main.d -L-L. -L-l:mod.a

main.d(1): Error: module mod is in file 'pack/mod.d' which cannot 
be read

Please answer why it happens.
Mar 19 2018
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 19 March 2018 at 14:07:52 UTC, Vindex wrote:
 dmd main.d -L-L. -L-l:mod.a
It still needs to know where to find the import file to get D information like names and types out of it that aren't in the lib (well they sorta are but not exactly, in any case it isn't implemented to try it now). So either still pass it mod.d there, which makes the library useless, or pass `-Isomething` where there's a `pack/mod.d` or `pack/mod.di` file with the function prototypes. dmd -H can make mod.di out of mod.d for you in some cases automatically.
Mar 19 2018
parent Vindex <vindex9 gmail.com> writes:
On Monday, 19 March 2018 at 14:31:05 UTC, Adam D. Ruppe wrote:
 On Monday, 19 March 2018 at 14:07:52 UTC, Vindex wrote:
 dmd main.d -L-L. -L-l:mod.a
It still needs to know where to find the import file to get D information like names and types out of it that aren't in the lib (well they sorta are but not exactly, in any case it isn't implemented to try it now). So either still pass it mod.d there, which makes the library useless, or pass `-Isomething` where there's a `pack/mod.d` or `pack/mod.di` file with the function prototypes. dmd -H can make mod.di out of mod.d for you in some cases automatically.
Thank you. Sorry, the library does not save the requested information.
Mar 19 2018