发布时间:2022-12-11 11:00
在Ubuntu 16.04下编译安装OpenCV 3.1及OpenCV多版本切换的过程。
第一步:更新驱动
Ubuntu 16.04的更新管理器集成了驱动更新,选择安装nivdia的驱动
第二步:安装cuda
sudo apt-get install nvidia-cuda-toolkit
cuda是7.5.18版,安装完后重启,在终端输入nivdia-smi,有结果则驱动和cuda安装成功。
但是cuda只支持gcc5.0以下,即使后续用cmake编译opencv成功,gpu还是无法调用
第三步:强制取消cuda的gcc版本检查
注释掉host_config.h中关于gcc版本的检查,版本大于5则返回错误
//#if __GNUC__ > 5
//#error -- unsupported GNU version! gcc versions later than 5 are not supported!
//#endif /* __GNUC__ > 5 */
1
2
3
//#if __GNUC__ > 5
//#error -- unsupported GNU version! gcc versions later than 5 are not supported!
//#endif /* __GNUC__ > 5 */
通过nvidia-cuda-toolkit安装的,host_config.h在 /usr/include/下,如果通过cuda的run文件安装,也会因为gcc版本检查提示错误,也要修改对应位置的host_config.h
法二:通过修改gcc版本降级
1
2
法二:通过修改gcc版本降级
第四部:安装OpenCV相关的库
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev libtbb-dev libboost-dev libeigen3-dev
sudo apt-get install libxml2-dev libxslt-dev libffi-dev libsdl1.2-dev libssl-dev libboost-all-dev
1
2
3
4
5
sudoapt-getinstallcmakegitlibgtk2.0-devpkg-configlibavcodec-devlibavformat-devlibswscale-dev
sudoapt-getinstallpython-devpython-numpylibtbb2libtbb-devlibjpeg-devlibpng-devlibtiff-devlibjasper-devlibdc1394-22-devlibtbb-devlibboost-devlibeigen3-dev
sudoapt-getinstalllibxml2-devlibxslt-devlibffi-devlibsdl1.2-devlibssl-devlibboost-all-dev
第五步:cmake编译
安装cmake-gui
ippicv_linux_20151201.tgz 下载到Linux公社1号FTP服务器下载
------------------------------------------分割线------------------------------------------
用户名:ftp1.linuxidc.com
密码:www.linuxidc.com
在 20177年LinuxIDC.com\1月\Ubuntu 16.04 编译安装OpenCV 3.1及OpenCV多版本切换\