I don't get why it is necessary to provide either rpath or set env varible using LD_LIBRARY_PATH when -L already tells where the shared Library path is.
this answer says: -L tells ld where to look for libraries to link against when linking.
But why at the same time the corresponding -rpath is not set automatically? why do we need to do it manually again?
P.S: I guess if you had that feature, then the executable would be useless in some other environment. But if it is so then what ld actually does during linking, or why it is necessary to give -L path if -rpath in some other environment is different.