一、准备工作:
CentOS-7-x86_64-DVD-1810(7.6版本)
ffmpeg-4.2.4.tar.xz 源码
opencv-4.5.5.zip 源码
以上三个库自己可以下载。
二、更换源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
三、安装依赖
yum -y install epel-release
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
yum install -y ant autoconf automake freetype-devel libtool
yum install -y gcc gcc-c++ cmake3 git pkgconfig gtk2 gtk2-devel gtk2-devel-docs python python-pip python-devel
yum install -y numpy gimp-devel gimp-devel-tools libtool-ltdl libtool-ltdl-devel* python-numpy libavc1394-devel
yum install -y gimp-help-browser libjpeg-devel libtiff-devel libpng-devel gstreamer-devel gstreamer-plugins-base-devel
yum install -y libraw1394-devel libdc1394-devel jasper-devel jasper-utils libv4l libv4l-devel
yum install -y zlib-devel unzip swig libtool nasm libgnomeui-devel gnome-devel gnome-devel-docs kernel-devel gcc-gfortran
四、编译ffmpeg
cd ffmpeg-4.2.4
./configure --enable-shared --enable-pic --prefix=/soft/ffmpeg
make -j8
make install
vim /etc/ld.so.conf.d/ffmpeg.conf
include ld.so.conf.d/*.conf
/soft/ffmpeg/lib/
ldconfig
vim /etc/profile
export PATH=$PATH:/soft/ffmpeg/bin
source /etc/profile
vim /etc/bashrc
export LD_LIBRARY_PATH=/soft/ffmpeg/lib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/soft/ffmpeg/lib/pkgconfig
export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:/soft/ffmpeg/lib
source /etc/bashrc
使opencv能找到ffmpeg
cp /soft/ffmpeg/lib/pkgconfig/* /usr/share/pkgconfig/
五、编译opencv
cd opencv-4.5.5
mkdir build
cd build
cmake3 -DCMAKE_BUILD_TYPE=Release -DWITH_1394=ON -DOPENCV_GENERATE_PKGCONFIG=ON -DCMAKE_INSTALL_PREFIX=/soft/opencv455 -DWITH_FFMPEG=ON -DBUILD_TESTS=OFF -DBUILD_opencv_world=ON ..
make -j8
make install
vim /etc/profile.d/pkgconfig.sh
在pkgconfig.sh文件中写入(可能是空文件):
export PKG_CONFIG_PATH=/soft/opencv455/lib64/pkgconfig:$PKG_CONFIG_PATH
最后:
source /etc/profile
source /etc/profile.d/pkgconfig.sh
vim /etc/ld.so.conf.d/opencv4.conf
在opencv4.conf文件中写入(可能是空文件):
/soft/opencv455/lib64
ldconfig
pkg-config --modversion opencv4
六、设置共享
su root
vmhgfs-fuse .host:/CentosShare /mnt/hgfs -o allow_other
七、编译自己的库
修改HXVDDLL.h
#define ON_WINDOWS 0
cd HXVDDLL
make
cp libHXVDDLL.so ../lib
cd ../AlgTest
make
cp testAlg ../lib
cd ../lib
./testAlg
如果出现找不到库的情况,需要添加环境变量
gedit /etc/ld.so.conf.d/HXVD.conf
/home/long/zl/HXVD/lib
ldconfig
/sbin/ldconfig.real: /home/long/zl/HXVD/lib/libopencv_world.so.4.5 is not a symbolic link
cd /home/long/zl/HXVD/lib
sudo ln -sf libopencv_world.so.4.5.5 libopencv_world.so.4.5
sudo ln -sf libopencv_world.so.4.5 libopencv_world.so
文章出处登录后可见!
已经登录?立即刷新