概述
下一篇:ncnn填坑记录二:安装ncnn
一.protobuf安装
1.下载
git clone https://gitee.com/arcy/protobuf.git # 网络不好才在码云下载,建议github
或
git clone https://github.com/protocolbuffers/protobuf.git
2.安装
安装依赖项:
sudo apt-get install autoconf automake libtool curl make g++ unzip libffi-dev -y
安装
cd protobuf/
./autogen.sh
./configure
make
sudo make install
sudo ldconfig // 刷新共享库,很重要的一步
3.报错
刷新共享库时,报错
/sbin/ldconfig.real: /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7 不是符号连接
libcudnn.so.7 -> libcudnn.so.7.6.5
终端输入:
sudo ln -sf /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7.6.5 /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7
再次刷新共享库sudo ldconfig
,无报错。
测试protobuf是否安装成功protoc –h
,正常显示无报错。
4.卸载protoc
sudo rm -rf /usr/local/bin/protoc
二.Cmake安装
1.下载
在https://cmake.org/files/选择cmake大版本(比如v3.10),进去后选择具体版本(比如cmake-3.10.2-Linux-x86_64.tar.gz)下载
解压至指定文件夹
2.安装
./configure
make -j8
sudo make install
3.报错
./configure
报错:
CMake Error at /home/lgy/anaconda3/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:15 (message):
The imported target "Qt5::Gui" references the file
"/usr/lib/x86_64-linux-gnu/libEGL.so"
but this file does not exist. Possible reasons include:
/usr/lib/x86_64-linux-gnu/libEGL.so
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/home/lgy/anaconda3/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake"
but not all the files it references.
解决方法:
参考https://blog.csdn.net/fb_941219/article/details/83549720
发现/usr/lib/x86_64-linux-gnu下的libEGL.so链接已断,删除后重新链接一个存在的目标
(base) lgy@lgy:/usr/lib/x86_64-linux-gnu$ ls /usr/lib/x86_64-linux-gnu | grep -i libegl
libEGL_nvidia.so.0
libEGL_nvidia.so.440.36
libEGL.so
libEGL.so.1
libEGL.so.1.1.0
(base) lgy@lgy:/usr/lib/x86_64-linux-gnu$ sudo rm -rf libEGL.so
[sudo] lgy 的密码:
(base) lgy@lgy:/usr/lib/x86_64-linux-gnu$ sudo ln libEGL.so.1 libEGL.so
重复第一步,还报错
- Checking support for ARCHIVE_CRYPTO_MD5_LIBMD
-- Checking support for ARCHIVE_CRYPTO_MD5_LIBMD -- not found
-- Checking support for ARCHIVE_CRYPTO_RMD160_LIBMD
-- Checking support for ARCHIVE_CRYPTO_RMD160_LIBMD -- not found
-- Checking support for ARCHIVE_CRYPTO_SHA1_LIBMD
-- Checking support for ARCHIVE_CRYPTO_SHA1_LIBMD -- not found
-- Checking support for ARCHIVE_CRYPTO_SHA256_LIBMD
-- Checking support for ARCHIVE_CRYPTO_SHA256_LIBMD -- not found
-- Checking support for ARCHIVE_CRYPTO_SHA512_LIBMD
-- Checking support for ARCHIVE_CRYPTO_SHA512_LIBMD -- not found
Curses libraries were not found. Curses GUI for CMake will not be built.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lgy/tools/cmake-3.10.2
不过不用在意,正常安装即可
(base) lgy@lgy:~/tools/cmake-3.10.2$ cmake --version
cmake version 3.10.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
4.查看版本号
(base) lgy@lgy:~/tools/cmake-3.10.2$ cmake --version
cmake version 3.10.2
5.cmake默认安装在
(base) lgy@lgy:~/tools/cmake-3.10.2$ which cmake
/usr/local/bin/cmake
若遇到安装cmake后,查看版本号时显示的版本为linux自带的低版本,可直接将安装包里的cmake覆盖到/usr/local/bin/cmake。
三.OpenCV安装
方法一:apt-get安装
简单直接,不需配置环境,缺点时安装的版本太低了
sudo apt-get install libopencv-dev python-opencv
查看版本
pkg-config --modversion opencv
2.4.9.1
方法二:用cmake构建安装
1.github上下载opencv和opencv_contrib,我下载的3.4版本的,为了方便将opencv_contrib移至opencv文件夹下,2.x版本不需要安装opencv_contrib。
2.安装依赖项
sudo apt install build-essential
sudo apt install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
3.编译安装,cmake时需指定opencv_contrib地址
cd opencv/
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/lgy/tools/opencv/opencv_contrib/modules ..
sudo make install -j8
# 查看opencv版本
pkg-config --modversion opencv
4.易报错的地方
①.安装依赖项时报错:使用sudo apt-get install 时出现提示无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
使用命令sudo aptitude install安装,选择 N Y Y .
②.ippicv和xfeatures2d报无法下载这种错,类似于
IPPICV:Download:ippicv_2019_lnx_intel64_general_20180723.tgz can‘t
connect to server
-- xfeatures2d/boostdesc: Download: boostdesc_bgm.i
-- Try 1 failed
还有缺少xx文件、无法找到xx文件这种错,建议直接开个vpn再安装,不然一个一个文件去找,费时不说,关键是国内网友提供的文件,有些版本不匹配或者哈希值不匹配,经常时解决了一个错误,又报另一个错误。
③.
类似于
/usr/bin/ld: warning: libpcre.so.1, needed by //home/lgy/anaconda3/lib/libglib-2.0.so.0, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libzstd.so.1.3.7, needed by //home/lgy/anaconda3/lib/libtiff.so.5, not found (try using -rpath or -rpath-link)
//home/lgy/anaconda3/lib/libtiff.so.5:对‘ZSTD_initCStream’未定义的引用
//home/lgy/anaconda3/lib/libtiff.so.5:对‘ZSTD_freeCStream’未定义的引用
或
/usr/bin/ld: warning: libpcre.so.1, needed by //home/lgy/anaconda3/lib/libgstreamer-1.0.so.0, not found (try using -rpath or -rpath-link)
//home/lgy/anaconda3/lib/libglib-2.0.so.0:对‘pcre_exec’未定义的引用
//home/lgy/anaconda3/lib/libglib-2.0.so.0:对‘pcre_study’未定义的引用
方法
cd /usr/lib/x86_64-linux-gnu
sudo ln -s ~/anaconda3/lib/libzstd.so.1
sudo ldconfig
sudo ln -s ~/anaconda3/lib/libffi.so.7
sudo ldconfig
sudo ln -s ~/anaconda3/lib/libpcre.so.1
sudo ldconfig
④.类似于
/usr/bin/ld: warning: libpng16.so.16, needed by //home/lgy/anaconda3/lib/libcairo.so.2, not found (try using -rpath or -rpath-link)
//home/lgy/anaconda3/lib/libcairo.so.2:对‘png_set_interlace_handling@PNG16_0’未定义的引用
//home/lgy/anaconda3/lib/libcairo.so.2:对‘png_set_IHDR@PNG16_0’未定义的引用
//home/lgy/anaconda3/lib/libcairo.so.2:对‘png_get_io_ptr@PNG16_0’未定义的引用
方法
1.cd /usr/lib/x86_64-linux-gnu
2.sudo ln -s ~/anaconda3/lib/libpng16.so.16 libpng16.so.16
3.sudo ldconfig
5.设置环境变量,参考链接
添加路径
sudo gedit /etc/ld.so.conf.d/opencv.conf
在打开的文件中添加
/usr/local/lib
保存退出,终端输入:
sudo ldconfig
sudo gedit /etc/bash.bashrc
打开文件后在末尾输入:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
保存退出,终端输入:
source /etc/bash.bashrc
6.测试 opencv
进入opencv/samples/cpp/example_cmake目录下,终端打开,依次输入:
cmake .
make
./opencv_example
最后会弹出一个显示“Hello OpenCV”的窗口,总算安装好opencv了。
最后
以上就是尊敬大白为你收集整理的ncnn填坑记录一:安装protobuf、cmake和opencv一.protobuf安装二.Cmake安装三.OpenCV安装的全部内容,希望文章能够帮你解决ncnn填坑记录一:安装protobuf、cmake和opencv一.protobuf安装二.Cmake安装三.OpenCV安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复