ubuntu下opencv安装编译出错

我的系统是Ubuntu 18.04.2,通过手动编译安装opencv3.4.2。

1.首先安装OpenCV的依赖文件,在终端运行下面命令:
[compiler] sudo apt-get install build-essential

[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

2.下载opencv3:
下载安装包,opencv-3.4.2.zip
解压,unzip opencv-3.4.2.zip

3.进入解压目录:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local …

4.编译
sudo make后报错:
$:sudo make
[sudo] password for :
[ 0%] Built target gen-pkgconfig
[ 3%] Built target libjpeg-turbo
[ 6%] Built target libtiff
[ 14%] Built target libwebp
[ 17%] Built target libjasper
[ 22%] Built target IlmImf
[ 24%] Built target ippiw
[ 30%] Built target libprotobuf
[ 30%] Built target ittnotify
[ 30%] Built target opencv_test_core_pch_dephelp
[ 30%] Built target opencv_core_pch_dephelp
[ 30%] Built target opencv_ts_pch_dephelp
[ 30%] Built target pch_Generate_opencv_ts
[ 30%] Built target pch_Generate_opencv_core
[ 36%] Built target opencv_core
[ 36%] Built target opencv_imgproc_pch_dephelp
[ 36%] Built target pch_Generate_opencv_imgproc
[ 41%] Built target opencv_imgproc
[ 41%] Built target opencv_imgcodecs_pch_dephelp
[ 41%] Built target pch_Generate_opencv_imgcodecs
[ 43%] Built target opencv_imgcodecs
[ 43%] Built target opencv_videoio_pch_dephelp
[ 43%] Built target pch_Generate_opencv_videoio
[ 43%] Linking CXX shared library …/…/lib/libopencv_videoio.so
/usr/bin/ld: cannot find -lgstbase-1.0
/usr/bin/ld: cannot find -lgstreamer-1.0
/usr/bin/ld: cannot find -lgstvideo-1.0
/usr/bin/ld: cannot find -lgstapp-1.0
/usr/bin/ld: cannot find -lgstriff-1.0
/usr/bin/ld: cannot find -lgstpbutils-1.0
/usr/bin/ld: cannot find -lavresample
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:333: recipe for target ‘lib/libopencv_videoio.so.3.4.2’ failed
make[2]: *** [lib/libopencv_videoio.so.3.4.2] Error 1
CMakeFiles/Makefile2:5205: recipe for target ‘modules/videoio/CMakeFiles/opencv_videoio.dir/all’ failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:162: recipe for target ‘all’ failed
make: *** [all] Error 2

有谁碰到过这个问题吗?

换了一个安装文件,问题解决
https://blog.csdn.net/hanhung/article/details/100822255

你可能感兴趣的:(ubuntu下opencv安装编译出错)