Search code examples
c++staticsharedautomakelibtool

Libtool Discards Static Library When Building Shared Library


I am trying to build a shared object for gstreamer. I have a static library that I need to link into it.

I have tried many things, but no matter what libtool discards my shared library.

I tried:

  1. -Wl,--whole-archive ${EZSDK}/linux-devkit/arm-none-linux-gnueabi/usr/lib/ti/sdo/linuxutils/cmem/lib/cmem.a470MV -Wl,--no-whole-archive But libtool simply removes it and shows -Wl,--whole-archive -Wl,--no-whole-archive

  2. I tried to add it to mylib_la_LIBADD=$(EZSDK)/linux-devkit/arm-none-linux-gnueabi/usr/lib/ti/sdo/linuxutils/cmem/lib/cmem.a470MV but that also did not work. The libtool echo shows the cmem.a470MV but when it executes the link, the archive is gone.

Could anyone offer any suggestions?


Solution

  • I solved this by giving libtool the finger and specifying

    -Wl,--whole-archive -Wl,${EZSDK}/linux-devkit/arm-none-linux-gnueabi/usr/lib/ti/sdo/linuxutils/cmem/lib/cmem.a470MV -Wl,--no-whole-archive
    

    Alternatively, you can:

    -Wl,--whole-archive,${EZSDK}/linux-devkit/arm-none-linux-gnueabi/usr/lib/ti/sdo/linuxutils/cmem/lib/cmem.a470M,--no-whole-archive