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

老子叫甜甜 提交于 2019-12-05 16:54:07

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

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 at http://opencv.org/downloads.html

  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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!