Can value of rpath be a symbolic link?
It sure can, but you misunderstood your problem, which is not about symbolic link, but about ~
expansion.
When you link your binary with -Wl,-rpath,~/symlink
, you end up with RPATH
that is literally ~/symlink
. Such a directory (or a symlink) does not exist.
When you type e.g. ls ~/symlink
into your shell, what actually happens is that your shell expands ~
to whatever $HOME
is set to, and then does a readdir
on the expanded result.
But dynamic linker does not perform any such expansion, and literally looks for ./~/symlink
, which of course doesn't exist.
What you want then is: -Wl,-rpath,$HOME/symlink
.