dub: Is it possible to have a library target and depend on it in the same dub config?
invalid at example.com
Fri Sep 18 14:35:03 UTC 2020
On Friday, 18 September 2020 at 14:01:55 UTC, Mike Parker wrote:
> On Friday, 18 September 2020 at 12:28:30 UTC, wjoe wrote:
>> 2 issues though.
>> - It doesn't build the library automatically, and
> You'll have to invoke dub once for each config. Just slap both
> commands in a script.
>> - Linking fails because error: ld: cannot find -llib<name>
>> Built it manually via dub --config=lib and it lives inside the
>> lib directory.
>> Then added lflags "-Llib" to the "app" configuration but that
>> didn't help. ld still can't find the file.
>> Then I passed the absolute path and ld still complains.
>> Any ideas as to why ?
> It's just a matter of getting the configuration right and
> making the linker happy. I don't think I've ever linked with
> anything other than system libraries on Linux, so I really
> don't know what it expects when linking with a custom shared
> library outside of the system path.
I usually either specify the target as a dependency in meson and
it just works, or I install the library and provide a pkconfig
I'm only using dub because of vibe and I hope it would just work
> Make sure that your library foo.so is named `libfoo.so`, when
> you pass the lib path along in dflags via -L, then make sure to
> change `libs "lib/foo"` to `libs "foo"`.
This did the trick.
> The initial failure may be because of the path in the library
> name. I remember reading somewhere long ago that if you're
> passing a path in the library name (instead of using the -L
> flag), then you have to specify the full file name, e.g.
> lib/libfoo.so. I don't know if dub will pass that along
> correctly though.
> Whatever the case, trying adding -v to your dub command line so
> you can see exactly what's dub is calling the compiler with.
> That may give you a hint.
It links correctly now, thanks a lot :)
The only issue left is that I need to build the library manually.
More information about the Digitalmars-d-learn