Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 25, 2020 library dependencies nightmare, D edition | ||||
---|---|---|---|---|
| ||||
Hello! I have two libraries, where library B depends on library A, where both libraries consist of multiple packages. Say my project (I'm using VisualD) folder layout is the following: C/: libA A_Package1 A_Package2 A_Package3 libB B_Package1 - Imports from libA.Package2 B_Package2 B_Package3 Executable Module - Imports from libB.Package1 Why am I getting "Error: module "Package1" is in file libA\Package2 which cannot be read" messages? I tried changing the folder layout so that LibA is inside a dependencies folder inside LibB, but nothing changed. What am I missing? |
February 25, 2020 Re: library dependencies nightmare, D edition | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcel | On 2/25/20 4:31 PM, Marcel wrote:
> Hello!
> I have two libraries, where library B depends on library A, where both libraries consist of multiple packages. Say my project (I'm using VisualD) folder layout is the following:
>
> C/:
> libA
> A_Package1
> A_Package2
> A_Package3
> libB
> B_Package1 - Imports from libA.Package2
> B_Package2
> B_Package3
> Executable Module - Imports from libB.Package1
>
> Why am I getting "Error: module "Package1" is in file libA\Package2 which cannot be read" messages? I tried changing the folder layout so that LibA is inside a dependencies folder inside LibB, but nothing changed. What am I missing?
>
It would be most helpful to have actual messages, because you might be missing something.
Several causes for such errors:
1. You are trying to read a file that it cannot find given the command line parameters
2. The file has a module that is different from the actual package/file it is in.
Could be something else too. Maybe you have the same package name from both libraries? That should work, as long as you don't define the same module in both packages.
-Steve
|
February 25, 2020 Re: library dependencies nightmare, D edition | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Tuesday, 25 February 2020 at 21:48:00 UTC, Steven Schveighoffer wrote:
> On 2/25/20 4:31 PM, Marcel wrote:
>> Hello!
>> I have two libraries, where library B depends on library A, where both libraries consist of multiple packages. Say my project (I'm using VisualD) folder layout is the following:
>>
>> C/:
>> libA
>> A_Package1
>> A_Package2
>> A_Package3
>> libB
>> B_Package1 - Imports from libA.Package2
>> B_Package2
>> B_Package3
>> Executable Module - Imports from libB.Package1
>>
>> Why am I getting "Error: module "Package1" is in file libA\Package2 which cannot be read" messages? I tried changing the folder layout so that LibA is inside a dependencies folder inside LibB, but nothing changed. What am I missing?
>>
>
> It would be most helpful to have actual messages, because you might be missing something.
>
> Several causes for such errors:
>
> 1. You are trying to read a file that it cannot find given the command line parameters
> 2. The file has a module that is different from the actual package/file it is in.
>
> Could be something else too. Maybe you have the same package name from both libraries? That should work, as long as you don't define the same module in both packages.
>
> -Steve
I can't give you the actual error messages right now, but both libraries have packages that define modules with the same name. For example, both libraries have packages with a module called "utility.d". Unfortunately, this isn't the only thing that causes compilation to fail though.
|
February 25, 2020 Re: library dependencies nightmare, D edition | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcel | On 2/25/20 5:26 PM, Marcel wrote:
>
> I can't give you the actual error messages right now, but both libraries have packages that define modules with the same name. For example, both libraries have packages with a module called "utility.d". Unfortunately, this isn't the only thing that causes compilation to fail though.
is this imported via:
import utility;
? or is it
import packagea.utility;
?
If the former, then that is definitely a problem I think. Two libraries can have the same package name, but cannot have the same top-level module name (you can't split modules).
But I think you might have a different error for that condition.
Make sure that whatever module it is complaining about has a correct module declaration in both libraries.
i.e. even if you have:
packagea/utility.d
packageb/utility.d
and you import via:
import packagea.utility;
make sure packagea/utility.d has the module declaration:
module packagea.utility;
-Steve
|
February 25, 2020 Re: library dependencies nightmare, D edition | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcel | On Tuesday, 25 February 2020 at 22:26:48 UTC, Marcel wrote:
> For example, both libraries have packages with a module called "utility.d".
This is why I now have a strict policy that ALL modules must have at least a two part name; company.utility or whatever.
alas not everyone follows that :(
|
February 25, 2020 Re: library dependencies nightmare, D edition | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcel | On Tue, Feb 25, 2020 at 10:26:48PM +0000, Marcel via Digitalmars-d-learn wrote: [...] > I can't give you the actual error messages right now, but both libraries have packages that define modules with the same name. For example, both libraries have packages with a module called "utility.d". Unfortunately, this isn't the only thing that causes compilation to fail though. Are these top-level modules? If they are contained under packages, e.g., package1.utility vs. package2.utility, it shouldn't be a problem. >From what you described, though, it looks like your compile command is missing some -I flags. I don't use VisualD so I can't help you in the details, but if there's some settings somewhere for include paths, that might be what you need to fix this problem. T -- People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird. -- D. Knuth |
February 25, 2020 Re: library dependencies nightmare, D edition | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Tuesday, 25 February 2020 at 22:35:07 UTC, Steven Schveighoffer wrote:
> On 2/25/20 5:26 PM, Marcel wrote:
>>
>> I can't give you the actual error messages right now, but both libraries have packages that define modules with the same name. For example, both libraries have packages with a module called "utility.d". Unfortunately, this isn't the only thing that causes compilation to fail though.
>
> is this imported via:
>
> import utility;
>
> ? or is it
>
> import packagea.utility;
>
> ?
>
> If the former, then that is definitely a problem I think. Two libraries can have the same package name, but cannot have the same top-level module name (you can't split modules).
>
> But I think you might have a different error for that condition.
>
> Make sure that whatever module it is complaining about has a correct module declaration in both libraries.
>
> i.e. even if you have:
>
> packagea/utility.d
> packageb/utility.d
>
> and you import via:
>
> import packagea.utility;
>
> make sure packagea/utility.d has the module declaration:
>
> module packagea.utility;
>
> -Steve
The issue isn't with the module declaration, it is declared and imported as package1.utility. I think its an issue with VisualD's feature of adding import paths of project dependencies...
|
Copyright © 1999-2021 by the D Language Foundation