www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to force DUB to make and use a dynamic library

Hello,

I'm not sure if this belongs here, so, sorry if it doesn't.

The problem I have is this as follows:
given...
...a C library, let's call it libfoo, which implements an API
...a D library, libbar, which wraps the libfoo API and provides 
some additional convenience functions; in the DUB config I 
specify target dynamicLibrary
...a D program which links against libbar

If I add libbar in the program's dub config like so:

dependency "libbar" version\"~master" path\"./libbar"

DUB will create a dynamic library if I invoke it in the library 
directory but will make a static library if it's invoked from the 
program directory, link against it and fail because it can't find 
symbols from libfoo

if I specify a subPackage like so:
subPackage {
   name "bar"
   targetType "dynamicLibrary"
   sourcePaths "./libbar/source/"
   dflags "-I./libbar/source/"
}

and add it like so:

dependency ":bar" version="*"

DUB still only builds a static library and linking fails because 
of missing libfoo  symbols.

If I add a linker option to also link against libfoo it still 
doesn't work, with the same symbols, even when libfoo is added 
after libbar.

But even if that would work that's not the point.

The question is how do I have DUB honor the dynamicLibrary target 
and create and link against libbar dynamically, which links to 
libfoo dynamically.

Extra question - is there something like CMake to replace DUB?
I'm really not fond of DUB, at all.
Like any 1 click solution it's great when it works and when it 
doesn't it's a major PITA.
Verbose output sucks because it's hard to read because it's 
flooding dozens of pages with several lines long paths containing 
UUIDs and a thousand times nested paths.
Also it's inconvenient that there are no man pages for DUB so I 
need to go online whenever I need to refer to the manual. Sooo 
annoying.

I appreciate the DUB team putting a ton of effort into it and 
making it available for free and my intention is not to call it a 
bad program or something. It's just incompatible with my work 
flow.
So if anyone knows alternatives more in the spirit of make and 
CMake, I'd like to try them...

Anyways, thanks for your time
Jun 12 2018