Question

What are the advantages or disadvantage of using the -qnoweakexp option for linking a shared library?

Was it helpful?

Solution

If -qnoweakexp is set, then no weak symbols are exported, meaning that your shared library will be smaller (if it has any weak symbols).

A weak symbol is some global that has been marked with a #pragma weak, or the compiler has decided is a weak symbol (e.g. I think functions marked as inline may be considered weak). When linking, if there are duplicate symbols present typically the first one wins, unless it's weak. The order is: first strong symbol wins, then if there are no strong symbol, then first weak wins.

-qnoweakexp builds your shared library without any symbol marked as weak. If your application never actually references weak symbols from this shared library then using this option makes sense as it will shrink it's size. However, if your application actually uses the weak symbols (functions or variables) then obviously this option is a bad idea as the symbol resolution will fail.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top