使用chgrpath可以修改rpath。
LINUX使用chrpath更改编译结果的rpath_柳鲲鹏-CSDN博客
如果编译中没有设置rpath呢?比如:
$ ldd libavcodec.so linux-vdso.so.1 (0x00007ffef77bf000) libswresample.so.3 => /lib/x86_64-linux-gnu/libswresample.so.3 (0x00007f0dcb08c000) libavutil.so.56 => /lib/x86_64-linux-gnu/libavutil.so.56 (0x00007f0dcaf63000) libvpx.so.7 => not found
安装patchelf
sudo apt install -y patchelf chrpath
修改rpath
patchelf --set-rpath /home/wuxi/lib-ffmpeg/lib libvpx.so.7
检查
$ ldd libavcodec.so linux-vdso.so.1 (0x00007ffd717f9000) libswresample.so.3 => /home/wuxi/lib-ffmpeg/lib/libswresample.so.3 (0x00007f9570e0b000) libavutil.so.56 => /home/wuxi/lib-ffmpeg/lib/libavutil.so.56 (0x00007f9570b4e000) libvpx.so.7 => /home/wuxi/lib-ffmpeg/lib/libvpx.so.7 (0x00007f9570864000)