c - Something about "-Wl,-rpath=." -


i have build shared library libc.so, , depends on liba.so , libb.so. , build test.c using libc.so via command:

gcc test.c -o test -fpic -i./ -l./ -lc 

it output error, not find symbols in liba.so , libb.so. know, tt can build successufully when add flags "-la -lb".

however not understood, why can build via following command:

gcc test.c -o test -fpic -i./ -l./ -lc -wl,-rpath=. 

i think liba.so , libb.so present in current directory. providing linking option -wl -rpath current directory. linker takes libraries in current directory , link symbols.

it not giving errors because of linker options have specified.

the next doubt might is, have specified directories search not specified libraries. how linker taking liba.so , libb.so libraries also? linker intelligent , thinks have forgot include these interdependent libraries (you might not know interdependency)but have specified path search dependent libraries. picks interdependent libraries.

i think works interdependency only. direct libraries should specified -l option think.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -