package modules and how to generate a shared library plus .di file (I)
kdevel
kdevel at vogtner.de
Thu Dec 7 16:39:14 UTC 2017
Given the functions void foo() and void bar() in their source
files mymod/foo.d and mymod/bar.d. Also I have a
mymod/package.d
```
module mymod;
public import foo : foo;
public import bar : bar;
```
and a client to the library:
main.d
```
import mymod;
void main ()
{
foo;
bar;
}
```
It compiles fine with
$ dmd main.d mymod/foo.d mymod/bar.d
Now I want to link against libmymod.a. First I prepare the
library:
$ dmd -lib -oflibmymod.a mymod/foo.d mymod/bar.d
and then
$ dmd main.d -L-L. -L-lmymod
(*)
mymod/package.d(3): Error: module foo is in file 'foo.d' which
cannot be read
import path[0] = .../linux/bin64/../../src/phobos
import path[1] = .../linux/bin64/../../src/druntime/import
In order to make that Error go away I have to change
package.d
```
module mymod;
public import mymod.foo : foo;
public import mymod.bar : bar;
```
Then (*) works as expected. But why do I have to use the prefix
"mymod.:" in the
library case?
More information about the Digitalmars-d-learn
mailing list