修复共享库g ++上的断开链接

时间:2011-08-07 19:46:08

标签: g++ shared dynamic-linking

我有一个链接到opencv 2.2的可执行文件。但是,我已经删除了opencv 2.2并且安装了opencv 2.3。

问题是,有没有办法将此可执行文件链接到新的共享库而无需重新编译整个源代码?我该如何修复那些破损的链接?

running ldd:

    linux-vdso.so.1 =>  (0x00007fff17fff000)
    libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fd6f0e0d000)
    libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fd6f0bf2000)
    libXmu.so.6 => /usr/lib/libXmu.so.6 (0x00007fd6f09d8000)
    libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007fd6f07c8000)
    libGLU.so.1 => /usr/lib/libGLU.so.1 (0x00007fd6f0559000)
    libGL.so.1 => /usr/lib/fglrx/libGL.so.1 (0x00007fd6f0353000)
    libopencv_core.so.2.2 => not found
    libopencv_imgproc.so.2.2 => not found
    libopencv_highgui.so.2.2 => not found
    libopencv_ml.so.2.2 => not found
    libopencv_video.so.2.2 => not found
    libopencv_features2d.so.2.2 => not found
    libopencv_calib3d.so.2.2 => not found
    libopencv_objdetect.so.2.2 => not found
    libopencv_contrib.so.2.2 => not found
    libopencv_legacy.so.2.2 => not found
    libopencv_flann.so.2.2 => not found
    libglut.so.3 => /usr/lib/libglut.so.3 (0x00007fd6f0109000)

...

谢谢你们,

塞缪尔

1 个答案:

答案 0 :(得分:4)

如果OpenCV版本2.3与版本2.2的二进制兼容,即如果ABI没有进行重大更改,您可以使用symbolic links解决问题:

# ln -s /usr/lib/libopencv_core.so.2.3 /usr/lib/libopencv_core.so.2.2
# ln -s /usr/lib/libopencv_imgproc.so.2.3 /usr/lib/libopencv_imgproc.so.2.2
.
.
.