how to link self made lib using dub

Timoses timosesu at gmail.com
Fri Jul 6 21:13:37 UTC 2018


On Friday, 6 July 2018 at 17:08:48 UTC, Flaze07 wrote:
> [...]
> then, I made a project, with this main in this path : 
> Z:\programming\D\experimentLib\source\main.d
>
> it contains this
>
> module main;
>
> import std.stdio;
>
> import source.output;

Shouldn't this be 'import output'?

>
> void main( string[] args ) {
>     Output.write( "lol" );
>     readln();
> }
>
> and then, I have a dub file in this path : 
> Z:\programming\D\experimentLib\dub.json
>
> it contains :
>
> {
>   "name" : "experimentlib",
>   "targetType": "executable",
>   "targetPath": "bin",
>   "importPaths": [
>     "Z:\\programming\\D\\usefulFiles\\experiment\\",

and this '...\\experiment\\source\\'? (I'm not accustomed to 
Windows..)

>   ],
>   "lflags": [
>     "+Z:\\programming\\D\\usefulFiles\\experiment\\lib\\",
>   ],
> }
>
> so, I have made lflags to include the lib in experiment, but 
> still, it failed to linker ( it compiles fine, but the linker 
> fails )

You could also add a dependency to your other dub project and dub 
should automatically add the import and linker flags.
Add this to your dub.json:

"dependencies":
{
     "experiment": {"version": "*", "path": "../experiment"}
}

I didn't test this now, but it should work something like that 
(again, not sure about Windows path...).

See also: 
http://code.dlang.org/package-format?lang=json#version-specs


More information about the Digitalmars-d-learn mailing list