Ask Your Question
0

help with jpeg error when installing OpenCV on Ubuntu 14.04

asked 2016-07-05 12:22:42 -0600

updated 2016-07-06 00:29:25 -0600

berak gravatar image

Hi!!!

I'm running the following script to install OpenCV:

version="2.4.9"
downloadfile="opencv-2.4.9.zip"
dldir="/home/marcelo"


if [[ -z "$version" ]]; then
        echo "Please define version before calling `basename $0` or use a wrapper like opencv_latest.sh"
        exit 1
fi
if [[ -z "$downloadfile" ]]; then
        echo "Please define downloadfile before calling `basename $0` or use a wrapper like opencv_latest.sh"
        exit 1
fi
if [[ -z "$dldir" ]]; then
        dldir=OpenCV
fi
echo "Installing OpenCV" $version
mkdir $dldir
cd $dldir
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"
sudo apt-get -qq install libopencv-dev build-essential #checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev #libjasper-dev libavcodec-dev libavformat-dev libswscale-dev #libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-#plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-#dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev #libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev #libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg unzip
echo "Downloading OpenCV" $version
wget -O $downloadfile http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$downloadfile/download
echo "Installing OpenCV" $version
echo $downloadfile | grep ".zip"
if [ $? -eq 0 ]; then
    unzip $downloadfile
else
    tar -xvf $downloadfile
fi
cd opencv-$version
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 BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j 4
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV" $version "ready to be used"

The script seems to be working fine, but at the end I get the following results:

[  6%] Built target opencv_imgproc
[  6%] Built target opencv_photo
[  6%] Built target opencv_video
Linking CXX shared library ../../lib/libopencv_highgui.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libjpeg.a(jcapimin.o): relocation R_X86_64_32S against `jpeg_natural_order' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libjpeg.a: error adding symbols: Bad value
collect2: error: 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
[  0%] Built target opencv_core_pch_dephelp
[  0%] Built target pch_Generate_opencv_core
[  3%] Built target opencv_core
[  3%] Built target opencv_ts_pch_dephelp
[  3%] Built target pch_Generate_opencv_ts
[  3%] Built target opencv_flann_pch_dephelp
[  3%] Built target pch_Generate_opencv_flann
[  3%] Built target opencv_flann
[  3%] Built target opencv_imgproc_pch_dephelp
[  3%] Built target pch_Generate_opencv_imgproc
[  6%] Built target opencv_imgproc
[  6%] Built target opencv_features2d_pch_dephelp
[  6%] Built target pch_Generate_opencv_features2d
[  6%] Built target opencv_highgui_pch_dephelp
[  6%] Built target pch_Generate_opencv_highgui
Linking CXX shared library ../../lib/libopencv_highgui.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libjpeg.a(jcapimin.o): relocation R_X86_64_32S against `jpeg_natural_order' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libjpeg.a: error adding symbols: Bad value
collect2: error: 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
OpenCV 2.4.9 ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-06 00:33:03 -0600

berak gravatar image

it seems, your script dragged in a wrong version of libjpeg.

try to add -DBUILD_JPEG to your cmake cmdline, and rerun cmake && make && make install

this should build & link the 3rparty libjpeg version, that comes with opencv (instead of trying to use your system one)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-05 12:22:42 -0600

Seen: 679 times

Last updated: Jul 06 '16