[Jack-Devel] weak linking on ubuntu

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Jack-Devel] weak linking on ubuntu

IOhannes m zmölnig
after a long session of debugging i finally found out the problem of a
friend of mine, why my jack-enabled application (hooray: Pd) would crash
on their system.

to cut it short:
- Pd is including <jack/weakjack.h> to support weak linking (mainly for
OSX; but while we are there, I think we'd like to support that on all
- Ubuntu-16.04LTS' linker seems to have "--as-needed" enabled by default.

now in general, I think that the "--as-needed" flag is nice, as it
removed plenty of cruft from all application.

unfortunately "man 1 ld" says:
  --as-needed causes a DT_NEEDED tag to only be emitted for
           a library that at that point in the link satisfies a non-weak
           undefined symbol reference from a regular object file

now, it seems that *all* symbols defined in <jack/jack.h> are defined as
this means that it is impossible for libjack to acquire a DT_NEEDED tag
for any application (since there are only weak symbols in libjack for
the application to depend on), which in turn means that the linker will
happily optimize away the dependency on libjack.

the application ends up not dylinking against libjack, with all symbols
being set to NULL.


$ cat <<EOF >myjack.c
#include <jack/weakjack.h>
#include <jack/jack.h>
int main() {
  jack_client_open("foobar", JackNoStartServer, 0, 0);
  return 0;
$ gcc -o myjack myjack.c  -Wl,--as-needed -ljack
$ ldd myjack | grep jack

with ubuntu-16.04LTS, the commandline is just
    gcc -o myjack myjack.c -ljack

this is certainly wrong.
i do want weak symbols in jack, and still be able to use jack if the
library is present and filled with symbols.
(in linux there we only have weak symbols anyhow; no "weak linking" as
in OSX where the .so file need not be present).

what's the proper way to make my application link against libjack,
without having to add special linker magic (that is not announced via


PS: on IRC, harry suggested that robin has some weirdo shit for this

Jack-Devel mailing list
[hidden email]

signature.asc (849 bytes) Download Attachment