how to build test.exe successfully,but not link A.so.
There are at least two method:
export a proper
LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/path/to/A gcc ... -lB
using
ld
option-rpath
(discovered by the asker @iceKing himself)gcc -Wl,-rpath=/path/to/A ...
In both case, ld
will automatically search for libraries depended by these libraries list explicitly.