Use chrpath under ubuntu16.
installation:
sudo apt install chrpath
View available options:
wmz@ubuntu:~$ chrpath --help
Usage: chrpath [-v|-d|-c|-r <path>] <program> [<program> ...]
-v|--version Display program version number
-d|--delete Delete current rpath/runpath setting
-c|--convert Convert rpath to runpath
-r <path>|--replace <path> Replace current rpath/runpath setting
with the path given
-l|--list List the current rpath/runpath (default)
-k|--keepgoing Do not fail on first error
-h|--help Show this usage information.
View version:
wmz@ubuntu:~$ chrpath -v
chrpath version 0.16
View the dependency path of the compiled program:
build$ chrpath -l demo
demo: RPATH=/mnt/hgfs/vmsharefolders/libtorch/lib:/home/wmz/Desktop/mypractice/pytorch-demo/../libs
Modify the dependent library path:
build$ chrpath -r ../../libs demo
demo: RPATH=../../libs
demo: new RPATH: ../../libs
Note that the middle line is the old path, and the last line is the new path. Originally, these two lines should be different, because I have executed it again before, and I will execute it again here just for notes.
Final advice: generally don't use this tool, otherwise you don't know how to solve the problem.