[patch] Too many libs in pkg-config --libs in --enable-shared case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there PJProject devs.

When compiling Asterisk, I encountered an error similar to this:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804460

The linker was told to include shared libraries that did not exist on the
system:

  x86_64-linux-gnu-gcc -o pjsip/dialplan_functions.o -c
     ...
     -lpjsua2 -lstdc++ -lpjsua -lpjsip-ua -lpjsip-simple
     -lpjsip -lpjmedia-codec -lpjmedia -lpjmedia-videodev
     -lpjmedia-audiodev -lpjmedia -lpjnath -lpjlib-util
     -lsrtp -lpj -lm -lrt -lpthread -lSDL2 -lavformat-ffmpeg
     -lavcodec-ffmpeg -lswscale-ffmpeg -lavutil-ffmpeg -lv4l2
     -lopencore-amrnb -lopencore-amrwb
  /usr/bin/ld: cannot find -lSDL2
  /usr/bin/ld: cannot find -lavformat-ffmpeg
  ...


I believe that the problem is caused by pkg-config --libs telling us to
include more libs than it should.

For example, on this system, it says:

  $ pkg-config --libs libpjproject
  -L/usr/local/lib -lpjsua2 -lstdc++ -lpjsua -lpjsip-ua
  -lpjsip-simple -  lpjsip -lpjmedia-codec -lpjmedia-videodev
  -lpjmedia-audiodev -lpjmedia -lpjnath -lpjlib-util -lsrtp
  -lgsmcodec -lspeex -lilbccodec -lg7221codec -lpj -luuid -lm
  -lrt -lpthread -lcrypto -lssl

The -luuid and -lm and -lrt and a few more should not be in that list.
They are used and linked by libpjsip.so (and others), so we don't need to
link to them another time:

  $ ldd /usr/local/lib/libpjsip.so | grep uuid
  libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fdf0a8da000)


Are more complete writeup is here:
http://wjd.nu/notes/2016#missing-sofiles-linker-asterisk


Attached is my attempt at fixing it.

* It adds a new make target: libpjproject.pc
  That way I didn't have to `make install` the entire time.

* It replaces a few `rmdir` with `$(HOST_RMDIR)` (and friends) for
  consistency.

* For the libpjproject.pc target, it checks whether any *.so is built.
  If so, it separates the dynamic libs from the privately used ones.

* If no *.so is built, the libpjproject.pc is built as it was before
  this change (with an additional empty "Libs.private" section).
  This way we won't cause unintentional breakage for static builds.


Let me know if this works for you (and if this is the right channel to
submit a patch).

Cheers!
Walter Doekes
OSSO B.V.

====

$ diff libpjproject.pc.original libpjproject.pc.after
12a13
> Libs.private:


$ cat libpjproject.pc.enable_shared | tail -n3
Libs: -L${libdir} -lsrtp -lresample -lgsmcodec -lspeex -lilbccodec
-lg7221codec -lportaudio -lpjsua2 -lpjsua -lpjsip-ua -lpjsip-simple
-lpjsip -lpjmedia-codec -lpjmedia-videodev -lpjmedia -lpjmedia-audiodev
-lpjnath -lpjlib-util -lpj
Libs.private: -lstdc++ -lssl -lcrypto -luuid -lm -lrt -lpthread -lavcodec
-lavutil -lv4l2
Cflags: -I${includedir} -I/usr/local/include -DPJ_AUTOCONF=1	-O2
-DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -fPIC

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_shared_lib_pkg_config.patch
Type: text/x-patch
Size: 3082 bytes
Desc: not available
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20160224/df327b1a/attachment.patch>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux