这几天调整安装,发现有些文件安装到/lib下。就想复制到安装目录,这样影响更少。然后发现rpaht有问题。怎么办?修改为当前路径最好。
.或者$ORIGIN
NEW_RPATH=.:/usr/local/lib/:/lib/aarch64-linux-gnu/
NEW_RPATH=\$ORIGIN:/usr/local/lib/:/lib/aarch64-linux-gnu/
在编译的时候,大多使用$ORIGIN。因为$有特殊含义,所以这里进行了转义。
patchelf --set-rpath ${RPATH} libopencv_video.so
chrpath -r ${RPATH} libopencv_video.so
# ldd libopencv_video.so
linux-vdso.so.1 (0x0000007fa127c000)
libopencv_imgproc.so.3.4 => /home/toybrick/work/libopencv_imgproc.so.3.4 (0x0000007fa0dd0000)
libopencv_core.so.3.4 => /home/toybrick/work/libopencv_core.so.3.4 (0x0000007fa0aae000)
libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007fa0923000)
libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007fa0866000)
libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007fa0842000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fa06d0000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007fa06bc000)
libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007fa068d000)
libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007fa0660000)
/lib/ld-linux-aarch64.so.1 (0x0000007fa124e000)
# ldd libopencv_video.so
linux-vdso.so.1 (0x0000007f9bb30000)
libopencv_imgproc.so.3.4 => /home/toybrick/package/pan/./libopencv_imgproc.so.3.4 (0x0000007f9b6a7000)
libopencv_core.so.3.4 => /home/toybrick/package/pan/./libopencv_core.so.3.4 (0x0000007f9b385000)
libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f9b1d7000)
libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f9b11a000)
libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f9b0f6000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f9af84000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f9af70000)
libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f9af41000)
libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007f9af14000)
/lib/ld-linux-aarch64.so.1 (0x0000007f9bb02000)
可以看到由编译的绝对路径,变成了相对路径。