I have a library (qui) that depends on the another library (termbox-d). And termbox-d links with a static library libtermbox.a
.
Note: the termbox-d I linked to has some bugs which I've fixed in my fork but pull request has yet to be merged.
And this is where things gets messed up:
If I compile qui
as a library, it will compile. Indicating that termbox-d
linked with libtermbox.a
.
If I compile qui
with dub build --comfig=demo
, it will build it as a executable with a main that uses qui
library which uses termbox-d
. This build and runs fine. Indicating that it still linked fine.
But if I create another package, that depends on qui
, and build it, it fails to link with libtermbox.a. I get errors like:
source/termbox/package.d:210: undefined reference to
tb_peek_event'
So now it failed to link with
libtermbox.a`
Why does this happen, and how I make it work?
Thanks to alphaglosined on IRC channel #d on chat.freenode.net, I figured out the issue:
Instead of adding
"sourceFiles" : ["libtermbox.a"]
to qui
's dub.json
, I had to add
"lflags" : ["$PACKAGE_DIR/libtermbox.a"]
.
And now it works.