Multi-library project path issue

#coder supetronix.dev1 at gmail.com
Fri May 25 19:43:04 PDT 2012


Thanks for the quick and helpful reply. I will give it a shot.



On Friday, 25 May 2012 at 06:36:07 UTC, Jacob Carlborg wrote:
> On 2012-05-25 08:15, #coder wrote:
>> Hi,
>>
>> I am using the Mono-D for building a project with 3-4 library 
>> projects
>> and one console project. Although I am using the Mono-D but I 
>> think this
>> issue is not unique to Mono-D. Please advise me with a 
>> solution, if I am
>> missing something obvious here.
>>
>> Issue;
>>
>> I have two "library" project with something similar to 
>> following:
>>
>> AppFolder (AppFolder contains the below two folders for 
>> individual project)
>>
>> Lib1
>> |
>> ------ TestFile1.d
>> |
>> ------ TestFile2.d (import TestFile1;) // TestFile2 is 
>> importing
>> TestFile1 in same library project.
>>
>>
>> Lib2 (Lib2 has linker path to "lib1.a" and include path to 
>> "AppFolder")
>> |
>> ------ TestFile3.d (import Lib1.TestFile2).
>>
>>
>> If I compile the Lib1 folder alone then it will work fine but 
>> now if I
>> compile the Lib2 folder then the error will be in 
>> "TestFile2.d" of Lib1
>> project that "TestFile1" is not found. If I change the 
>> "Import" in
>> TestFile2 to
>>
>> import Lib1.TestFile1;
>>
>> Then the compilation of Lib2 starts to work. Now, if I try to 
>> compile
>> the Lib1 project alone in Mono-D (I also tried same on D-IDE) 
>> then it
>> will not compile.
>>
>> I was ok with compiling only the Lib2 but now the next issue 
>> is that the
>> code completion won't work in "Lib1.TestFile2" after changing 
>> the import
>> statement (simply because Lib1.TestFile1 is not valid path for 
>> it any
>> more).
>>
>>
>> What should I do? How are other people working on 
>> multi-library projects
>> in D? I tried to look into generating the ".di" files but I 
>> don't think
>> that will work either. I looked at "Phobos" and it uses the 
>> convention
>> like "Lib1.TestFile2" (std.conv) but I don't think it will 
>> help me with
>> the compilation of Lib1 project.
>>
>>
>> Thanks
>
> It depends on what naming scheme you want to have on your 
> modules. I think you should go with "Lib1.TestFile1". Actually 
> I would go with lower case package names, i.e. 
> "lib1.TestFile1". In that case you need to add a flag to DMD to 
> indicate the import search path. This search path should point 
> to the parent folder of the root package(s), in this case the 
> parent folder of "Lib1", i.e. AppFolder.
>
> AppFolder
>   |- main.d
>   |- Lib1
>      |- TestFile1.d
>      |- TestFile2.d
>   |- Lib2
>      |- TestFile3.d
>         |- Lib3
>            |- TestFile4.d
>
> $ dmd AppFolder/main.d -I./AppFolder
>
> The module and import declarations of the TestFiles should look 
> like this:
>
> module Lib1.TestFile1;
>
> import Lib1.TestFile2;
> import Lib2.TestFile3;
> import Lib2.Lib3.TestFile4;
>
> For Mono-D you need to be able to specify the same search path. 
> I have no idea how to do that in Mono-D.




More information about the Digitalmars-d-learn mailing list