2014-05-28

gcc does not link unused lib it used to before

How to force gcc to link an otherwise unused library to your executable:

Add -Wl,--no-as-needed before your lib, and -Wl,--as-needed after.

Example: LDFLAGS=-L/opt/informix/lib/esql/ -lm -Wl,--no-as-needed -lifgls -Wl,--as-needed -liodbc
This example will force linking libifgls.so but libiodbc.so will be left out, if not used.