Install the specified version of OpenCV on Ubuntu (one-click installation)

First specify the version number and the number of CPU cores

export OPENCV_VERSION=4.6.0
export NUM_JOBS=8

download and unzip

wget -O https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
unzip opencv.zip && \
cd opencv-${OPENCV_VERSION} && \
mkdir -p build && cd build

compile and install

cmake -DCMAKE_BUILD_TYPE=Release -DOPENCV_GENERATE_PKGCONFIG=YES -DWITH_GTK=ON -DBUILD_TFF=ON -DWITH_EIGEN=OFF  -DENABLE_PRECOMPILED_HEADERS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/opencv4.6.0 ..
sudo make install -j${NUM_JOBS}

potential problem

…/…/lib/libopencv_imgcodecs.so.5.0.0: undefined reference to `TIFFReadRGBAStrip@LIBTIFF_4.0’

cmake选项中加上:BUILD_TIFF=ON

Removed the so file of libtiff in anconda

sudo rm /home/ztyf/anconda3/lib/libtiff.so* 

Resolving libpangoft2-1.0.so.0: undefined reference to 'pango_font_get_hb_font'

locate libpangoft2-1.0.so.0
选择/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0,将其拷贝到报错的路径完全解决。

Compile opencv cuda version under Ubuntu //lib/x86_64-linux-gnu/libblkid.so.1 undefined 'uuid_unparse@UUID_1.0'

sudo rm /home/xing/anaconda3/lib/libuuid.so.1

sudo ln -s /lib/i386-linux-gnu/libuuid.so.1 /home/xing/anaconda3/lib/libuuid.so.1

之后重新cmake;  sudo make -j8;   sudo make install;

reference

Guess you like

Origin blog.csdn.net/weixin_42990464/article/details/130921827