VD with Project references

Rainer Schuetze via Digitalmars-d-ide digitalmars-d-ide at puremagic.com
Wed Sep 16 14:45:05 PDT 2015



On 16.09.2015 04:09, Prudence wrote:
> One problem I have with VD is that when I have multiple projects, all
> using the same library I have to include it in each one. The changes are
> not synchronized and this becomes a mess.
>
> I've done the following.
>
> Suppose my Library is at C:\Library, my main project is at C:\Main
>
> 1. I made the secondary projects depend on the main project(project
> dependencies in VS).
>
> 2. I set the additional libraries to C:\Library and I've set the "Object
> Files" to C:\Main\Debug\main.obj (where the main.obj is the main project
> with the library in it, which compiles and exists)
>
> I've also set the "Library Files" to point to the library(C:\Library),
> but still get the following result:
>
> 3. The errors I get are about missing symbols:
>
> Debug\main.obj(Test)
>   Error 42: Symbol Undefined _D6Coding11ObjectStore7__arrayZ
> Debug\main.obj(Test)
>   Error 42: Symbol Undefined _D6Coding11ObjectStore12__ModuleInfoZ
> Building Debug\Test.exe failed!
>
> Any ideas?
>
> shouldn't main.obj contain the elements or, I guess I'd have to use
>
>
> 4. I've tried some of the other settings but nothing... (adding library
> path to sc.ini)
>
> 5. I don't mind compiling the library(maybe it should be in it's own
> project) for each project since it is small right now. But basically
> it's a no go until the problem gets solved in some way or another. It
> should be nice, if one could just add a reference to the main project
> like what is done with .NET
>

I can't really follow what you've been doing, but that's maybe because I 
don't use C# very often. D follows the link model of C/C++:

- if you have code shared between different projects, put it into a 
project that builds to a static library

- an executable using the library needs a 'project dependency' to the 
library, but does not need to include/compile the files of the library 
itself. Visual D will automatically add the output file of the library 
project to the link command line for the executable

- you'll probably need to import files from the library, so you have to 
add the library source folder to the "additional imports" option

The last option could also be set automatically for existing project 
dependencies, that's something I wanted to add eventually.


More information about the Digitalmars-d-ide mailing list