OpenCV编译错误链接CXX共享库../../lib/libopencv_highgui.so /lib/libbz2.so.1:无法读取符号:文件格式错误

时间:2014-11-13 06:18:11

标签: opencv cmake

我正在尝试在我的CentOS 6.4上安装OpenCV-2.4.9。机。
我在〜/ Downloads / opencv-2.4.9中下载了源代码 从那里,我做了'mkdir build; cd build'。然后做了

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON --enable-shared ..

并且'做'-j2' 下面是我收到的消息(这是使用'make'重新运行的结果)

[  3%] Built target libtiff
[  4%] Built target opencv_core_pch_dephelp
[  4%] Built target pch_Generate_opencv_core
[  6%] Built target opencv_core
[  6%] Built target opencv_ts_pch_dephelp
[  6%] Built target pch_Generate_opencv_ts
[  6%] Built target opencv_imgproc_pch_dephelp
[  7%] Built target pch_Generate_opencv_imgproc
[ 11%] Built target opencv_imgproc
[ 11%] Built target opencv_flann_pch_dephelp
[ 11%] Built target pch_Generate_opencv_flann
[ 12%] Built target opencv_flann
[ 12%] Built target opencv_highgui_pch_dephelp
[ 12%] Built target pch_Generate_opencv_highgui
Linking CXX shared library ../../lib/libopencv_highgui.so
/lib/libbz2.so.1: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[2]: *** [lib/libopencv_highgui.so.2.4.9] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2

我做了一些搜索,但没有好的答案。任何人都能给我一个关于错误的暗示吗?

1 个答案:

答案 0 :(得分:5)

我遇到了同样的问题,我的解决方案是删除所有构建文件(或CMakeCache.txt)并再次使用cmake。

问题是cmake找到了一个32位的库而不是64位的库,它应该在/lib64/libbz2.so或/usr/lib64/libbz2.so中找到。 有时cmake搞砸了并继续使用缓存变量。因此,如果您再次删除缓存并进行cmake,它应该找到正确的库。