Visual D: Settings to Improve compil and link process

ParticlePeter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 6 10:51:06 PDT 2014


On Sunday, 6 July 2014 at 08:09:07 UTC, Rainer Schuetze wrote:
>
>
> On 05.07.2014 16:05, ParticlePeter wrote:
...
>> It is possible to remove the template methods from my classes, 
>> create
>> free functions instead and use them in a UFCS way.
>> Unfortunately I have not figured out UFCS properly, as my 
>> approaches do
>> not work ( guess due to UFCS restrictions ).
>>
>
> That would not help, templates are instantiated and compiled 
> when they are used, not when they are declared.

Hence the idea of splitting the class. After the split, the class 
has only non-template methods and is part of MyLib. Template UFCS 
functions working with this class are in another module, and not 
part of the lib. With this approach MyLib does not need to 
recompile, only the UFCS functions module needs to recompile due 
to different instantiations. UFCS works now for me btw.


>> I tried to not build MyLib at all, and use the sources 
>> directly, but the
>> project setup is kind of confusing. Again, there is a setting 
>> which I
>> seem to not understand fully. So one project, lets say 
>> MyProject, has
>> only its own module files added to the VisualD project. I want 
>> the
>> compiler to also use the MyLib source files, but do not want 
>> to add them
>> to MyProject, reasoning bellow. There is one entry in the 
>> project
>> properties, which should make this behavior possible, but it 
>> doses not.
>> Why ?
>>
>> Configuration Properties - Compiler - General - Additional 
>> Imports
>>
>> As far as I understand this setting, I am supposed to enter 
>> module
>> search paths.
>
> This is correct.
>
> > But I do get linker errors when I do not add either
>> MyLib.lib to the linker settings or all the source files of 
>> MyLib to
>> MyProject.
>>
>
> You should add a dependency in the "Project -> Project 
> Dependencies" dialog. This will ensure proper rebuilds and add 
> the library to the command line of dependent projects.

The idea is to NOT create a lib, but just use the source code 
from MyLib in MyProject as additional includes. No project 
dependencies. I was hoping that some .obj files are still 
available from last builds, and do not need to recompile, as they 
are up to date ( reason for question about not cleaning files ).
The modules form MyProject do import the MyLib modules properly, 
I do not get compiler errors. However, the compiler should create 
Object files from MyLib modules, and the linker should link them. 
But he does not.
On the other hand, when I add MyLib modules to MyProject ( 
Rightclick MyProject - add - existing item... MyLib source files 
) then linking works. I do not understand why the later step is 
necessary.


More information about the Digitalmars-d-learn mailing list