Centos7 编译安装Cmake+ffmpeg
1、系统准备安装好Centos7.9并打好系统补丁安装一些常用工具关闭防火墙yum -y update yum -y install git yum -y install vim yum -y install unzip yum -y install net-tools yum -y install wget yum -y install openssl-devel yum -y install bzip2 gcc gcc-c gmp-devel mpfr-devel libmpc-devel make cmake yum -y install zlib yum -y install zlib-devel关闭SELINUXgetenforce ##查看下状态 vim /etc/selinux/config ##修改配置文件将SELINUXenforcing改为SELINUXdisabled reboot ##重启后生效关闭防火墙systemctl status firewalld.service ##查看防火墙运行状态 systemctl disable firewalld.service ##从下次开始关闭防火墙 systemctl stop firewalld.service ##关闭防火墙2、yum安装gcc8添加上CentOS SCLo RH库装上gdb8的依赖devtoolset-8-buildsudo yum -y install centos-release-scl-rh sudo yum -y install devtoolset-8-build安装相应的gdbsudo yum -y install devtoolset-8-gdb同样也可以安装相应版本的gcc-gsudo yum -y install devtoolset-8-gcc devtoolset-8-gcc-cyum安装完后原来的gcc不覆盖所以需要执行enable脚本更新环境变量sudo source /opt/rh/devtoolset-8/enable ##有时候提示没有文件需要进入到目录下运行source enable既可 cd /opt/rh/devtoolset-8/ source enable gcc -version ##检查gcc 版本是否切换到 gcc 8了 scl enable devtoolset-8 bash ##或者这个命令启用可以通过加入到profile里面开机自动source,vim /etc/profile, 跳到最后一行加入以下内容source /opt/rh/devtoolset-8/enable3、安装Cmake 3.21.0下载源码包并编译安装cd /home wget https://github.com/Kitware/CMake/releases/download/v3.21.0-rc3/cmake-3.21.0-rc3.tar.gz tar -xvf cmake-3.21.0-rc3.tar.gz mv cmake-3.21.0-rc3 cmake ##重新命名包 cd cmake ./bootstrap make -j4 make install cd /home/cmake/bin cmake ##测试cmake如下文则安装正常。 ##Usage ## cmake [options] path-to-source ## cmake [options] path-to-existing-build ## cmake [options] -S path-to-source -B path-to-build ##Specify a source directory to (re-)generate a build system for it in the ##current working directory. Specify an existing build directory to ##re-generate its build system. ##Run cmake --help for more information.4.安装ffmpeg4.1、编译安装创建编译目录cd /home mkdir ffmpeg_sources/ cd /home/ffmpeg_sources/安装NASMcurl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 tar -xvf nasm-2.14.02.tar.bz2 yum -y install autoconf automake libtool cd nasm-2.14.02 ./autogen.sh ./configure --prefix$HOME/ffmpeg_build --bindir$HOME/bin make -j4 make install安装Yasmcd /home/ffmpeg_sources curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar -xvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure --prefix$HOME/ffmpeg_build --bindir$HOME/bin make -j4 make install安装libx264cd /home/ffmpeg_sources git clone --depth 1 https://code.videolan.org/videolan/x264.git cd x264 PKG_CONFIG_PATH$HOME/ffmpeg_build/lib/pkgconfig ./configure --prefix$HOME/ffmpeg_build --bindir$HOME/bin --enable-static make -j4 make install安装libx265cd /home/ffmpeg_sources git clone https://github.com/videolan/x265.git cd /home/ffmpeg_sources/x265/build/linux cmake -G Unix Makefiles -DCMAKE_INSTALL_PREFIX$HOME/ffmpeg_build -DENABLE_SHARED:booloff ../../source make -j4 make install安装libfdk_aaccd /home/ffmpeg_sources git clone --depth 1 https://github.com/mstorsjo/fdk-aac cd fdk-aac autoreconf -fiv ./configure --prefix$HOME/ffmpeg_build --disable-shared make -j4 make install安装libmp3lamecd /home/ffmpeg_sources curl -O -L https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz tar -xvf lame-3.100.tar.gz cd lame-3.100 ./configure --prefix$HOME/ffmpeg_build --bindir$HOME/bin --disable-shared --enable-nasm make -j4 make install安装libopuscd /home/ffmpeg_sources curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz tar -xvf opus-1.3.1.tar.gz cd opus-1.3.1 ./configure --prefix$HOME/ffmpeg_build --disable-shared make -j4 make install安装libvpxcd /home/ffmpeg_sources git clone https://github.com/webmproject/libvpx.git cd libvpx ./configure --prefix$HOME/ffmpeg_build --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --asyasm make -j4 make install下载并编译ffmpegcd /home/ffmpeg_sources curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 tar -xvf ffmpeg-snapshot.tar.bz2 cd ffmpeg export PATH$HOME/bin:$PATH export PKG_CONFIG_PATH$HOME/ffmpeg_build/lib/pkgconfig ./configure \ --prefix$HOME/ffmpeg_build \ --pkg-config-flags--static \ --extra-cflags-I$HOME/ffmpeg_build/include \ --extra-ldflags-L$HOME/ffmpeg_build/lib \ --extra-libs-lpthread \ --extra-libs-lm \ --bindir$HOME/bin \ --enable-gpl \ --enable-libfdk_aac \ --enable-libmp3lame \ --enable-libopus \ --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ --enable-nonfree make -j4 make install ##最终编译完安装路劲在/root/bin 下面。上面的配置参数$HOME,为当前用户的根目录则root账号在root文件夹下面
