Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Ubuntu 14.04) apt-get libopencv-dev, but get errors: Unable to correct problems, you have held broken packages

Reading package lists... Done Building dependency tree
Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libopencv-dev : Depends: libopencv-objdetect-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libopencv-highgui-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libopencv-legacy-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libopencv-contrib-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libopencv-videostab-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libopencv-superres-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libopencv-ocl-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libcv-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libhighgui-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
                 Depends: libcvaux-dev (= 2.4.8+dfsg1-2ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

also, I used "aptitude install libopencv-dev", but it did not work. So I don't know how to finished this problem.

like image 474
Issac Avatar asked Dec 24 '22 23:12

Issac


2 Answers

The packages in the official repos are outdated, don't use them. This is what I use to install OpenCV, should work for you too.

sudo apt-get install build-essential make cmake git libgtk2.0-dev pkg-config python python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev
cd ~/Downloads
git clone https://github.com/itseez/opencv
mv opencv /opt
cd /opt/opencv
git checkout 2.4.10.1 #or whatever version you want
sudo mkdir build
cd build
sudo cmake -j4 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo make -j4
sudo make -j4 install
sudo ldconfig

Refer to this http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html

like image 188
texasflood Avatar answered Dec 27 '22 12:12

texasflood


I needed the OpenCV 3.2 and with the needs of enabling hardware acceleration modules and i followed this procedure on ubuntu 14.04.5:

  1. download the required libraries:
sudo apt-get install
  build-essential \
  cmake \
  git \
  libgtk2.0-dev \
  pkg-config \
  libavcodec-dev \
  libavformat-dev \
  libswscale-dev \
  python-dev \
  python-numpy \
  libtbb2 \
  libtbb-dev \
  libjpeg-dev \
  libpng-dev \
  libtiff-dev \
  libjasper-dev \
  libdc1394-22-dev
  1. download opencv

  2. extract, cd in the directory and run:

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=OFF -D WITH_OPENGL=ON -D WITH_OPENCL=ON -D WITH_VA_INTEL=ON -D BUILD_SHARED_LIBS=ON ..

make -j8 #to run 8 different jobs in parallel

sudo make install

add the line "export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH" to the .bashrc file

sudo ldconfig

Hope it can help

like image 42
Bbeon Avatar answered Dec 27 '22 11:12

Bbeon