I'm trying to build opencv for my x86_64 Centos 6 operating system.

I think the problem is make is trying to use the 32 bit version of the bz2 library instead of the 64 bit version.

I get this error from make:

[ 17%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_decoder.cpp.o
[ 17%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dc1394_v2.cpp.o
[ 17%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_gstreamer.cpp.o
[ 19%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_v4l.cpp.o
[ 19%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o
Linking CXX shared library ../../lib/libopencv_videoio.so
/lib/libbz2.so.1: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[2]: *** [lib/libopencv_videoio.so.3.1.0] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2

And I run cmake like this:


I have the library installed:

[root@localhost build]# ldconfig -p | grep libbz2
    libbz2.so.1 (libc6,x86-64) => /lib64/libbz2.so.1
    libbz2.so.1 (libc6) => /lib/libbz2.so.1

What can I do to fix this problem? Thanks!

EDIT: I also have the directories /lib and /lib64 and in /lib64 I have libbz2.so.1 and libbz2.so.1.0.4

EDIT: And I'm following these instructions http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html

1 Answer 1


After browsing several other Q&A sites, I came up with the problem being that cmake is using the 32 bit library as if it were the 64 bit one.

I solved this on Fedora 22 by doing this:

  1. remove your CMakeCache.txt file

  2. run cmake to regenerate it

    cmake -D blah blah flags and values
  3. Edit your CMakeCache.txt file and change this line

    //Path to a library.

    to this

    //Path to a library.
  4. Run cmake again (not sure if needed but just in case)

  5. make

It then finished without errors

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .