Chan Kim
Chan Kim

Reputation: 5989

OpenCV compile error Linking CXX shared library ../../lib/libopencv_highgui.so /lib/libbz2.so.1: could not read symbols: File in wrong format

I'm trying to install OpenCV-2.4.9 on my CentOS 6.4. machine.
I downloaded the source in ~/Downloads/opencv-2.4.9.
from there, I did 'mkdir build; cd build'. Then did

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 ..

and did 'make -j2'.
Below is the message I got (this is result of re-running using just '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

I did some search, but no good answers. Can anybody give me a hint on what's wrong?

Upvotes: 2

Views: 15790

Answers (1)

Weipeng He
Weipeng He

Reputation: 86

I had the same problem and my solution is remove all build file (or CMakeCache.txt) and cmake again.

The problem is that cmake finds a 32-bit library rather than the 64-bit one, which should be found in /lib64/libbz2.so or /usr/lib64/libbz2.so. Sometimes the cmake get messed up and keep using the cached variable. So if you remove the cache and cmake again, it should find the correct library.

Upvotes: 7

Related Questions