KuiperInfer项目地址
Github项目地址
B站课程地址
安装Armadillo
官网:Armadillo官网
介绍:Armadillo C++ Library是一种C++的线性代数库,包含一些矩阵和向量的运算,可以选用高效的LAPACK和BLAS进行加速。
矩阵相关计算的文档:使用手册
安装之前:
使用Linux对应发行版的包管理器安装必要的组件
Fedora & Red Hat: cmake, openblas-devel, lapack-devel, arpack-devel, SuperLU-develUbuntu & Debian: cmake, libopenblas-dev, liblapack-dev, libarpack2-dev, libsuperlu-dev
安装依赖包:
sudo apt update
sudo apt install cmake libopenblas-dev liblapack-dev libarpack2-dev libsuperlu-dev
安装Armadillo:
sudo apt-get install libarmadillo-dev
安装目录:
头文件安装在:
/usr/include/
库文件安装在:
/usr/lib/x86_64-linux-gnu
寻找usr目录:
find usr forder: cd /usr
安装cmake
首先安装gcc和g++
sudo apt install gcc
sudo apt install g++
然后下载安装openssl(因为cmake与openssl存在依赖关系)
下载地址:openssl官网
进入download目录
tar -xvf openssl-1.1.1t.tar.gz
cd openssl-1.1.1t
./config --prefix=/usr/local --openssldir=/usr/local/openssl
然后下载安装cmake
下载地址:cmake官网
tar -xvf cmake-3.26.0-rc4.tar.gz
cd cmake-3.26.0-rc4
./bootstrap
make
make install
cmake测试
cmake –version
安装成功
安装GTest测试库和Glog日志库
googletest官网
glog官网
先安装glog,再gtest,两个之间有依赖关系
mkdir build 在当前目录下创建一个build文件夹
cd build 进入刚创建的build文件夹
cmake ..
make -j8
make install
库文件在: /usr/local/lib/
头文件:/usr/local/include/
增加库寻找路径
vim ~/.bashrc
source ~/.bashrc
gtest安装
mkdir build
cd build
cmake ..
make -j8
make install
库文件在: /usr/local/lib/
头文件:/usr/local/include/
安装Opencv
Opencv官网:Opencv官网
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev libtiff5-dev
下载Opencv源码到用户下载目录:
执行命令:
cd 下载/
unzip opencv-4.8.0.zip
cd opencv-4.8.0/
mkdir build
cd build/
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo make -j8
sudo make install
添加路径:
// 打开文件并编辑
sudo vim /etc/ld.so.conf
// 在文件末尾添加以下代码
/usr/loacal/lib
// 保存文件并关闭,运行以下代码
sudo ldconfig
配置环境:
// 编辑.bashrc文件
sudo vim /etc/bash.bashrc
// 添加以下代码到文件末尾
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
// 关闭并保存.bashrc文件
// 执行命令
source /etc/bash.bashrc
此时输入以下命令,可能会报错,说找到不到OPencv
pkg-config opencv --modversionPackage opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
解决方案:创建opencv.pc文件
cd /usr/local/lib
sudo mkdir pkgconfig
cd pkgconfig
sudo touch opencv.pc
并在该文件中添加信息,注意这些信息需要与自己安装opencv时的库路径对应
prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/libName: opencv
Description: The opencv library
Version:4.0.1
Cflags: -I${includedir}/opencv4
Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
~
保存并退出文件,将文件导入到环境变量:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
测试:产生如下信息表示安装完成
jasmine@lhl:~/prj/KuiperInfer/build$ pkg-config --cflags --libs opencv
-I/usr/local/include/opencv4 -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
安装google benchmark
Google benchmark仓库地址:google benchmark官网
依次执行以下命令:
git clone https://github.com/google/benchmark.git
cd benchmark
cmake -E make_directory "build"
cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
cmake --build "build" --config Release
cmake -E chdir "build" ctest --build-config Release
sudo cmake --build "build" --config Release --target install