www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - library dependencies nightmare, D edition

reply Marcel <marcelpi97 gmail.com> writes:
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?
Feb 25 2020
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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
Feb 25 2020
parent reply Marcel <marcelpi97 gmail.com> writes:
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.
Feb 25 2020
next sibling parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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
Feb 25 2020
parent Marcel <marcelpi97 gmail.com> writes:
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...
Feb 25 2020
prev sibling next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
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 :(
Feb 25 2020
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
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
Feb 25 2020