[运维]在Centos7.9下编译ZLMediaKit

系统环境

系统版本:centos7.9.2009

编译版本说明

Gcc 4.8.5

环境设置

export PKG_CONFIG_VERSION=0.29.2
export CMAKE_VERSION=3.18
export CMAKE_FULL_VERSION=3.18.4
export YASM_VERSION=1.3.0
export NASM_VERSION=2.15.05
export X265_VERSION=3.4

编译工具安装

sudo yum install -y  \
        gcc \
        gcc-c++ \
        kernel-devel \
        kernel-headers \
        openssl \
        openssl-devel \
        git \
        wget \
        which

编译依赖及工具编译安装

  1. pkg-config
cd ~
wget https://pkgconfig.freedesktop.org/releases/pkg-config-${PKG_CONFIG_VERSION}.tar.gz \
    && tar -zxvf pkg-config-${PKG_CONFIG_VERSION}.tar.gz \
    && cd pkg-config-${PKG_CONFIG_VERSION} \
    && ./configure --with-internal-glib \
    && make -j8 \
    && sudo make install
  1. cmake
cd ~
wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_FULL_VERSION}.tar.gz \
    && tar -zxvf cmake-${CMAKE_FULL_VERSION}.tar.gz \
    && cd cmake-${CMAKE_FULL_VERSION} \
    && ./bootstrap \
    && gmake -j8 \
    && sudo gmake install 
  1. yasm
cd ~
 wget http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz \
    && tar zxvf yasm-${YASM_VERSION}.tar.gz \
    && cd yasm-${YASM_VERSION} \
    &&  ./configure \
    && make -j8 \
    && sudo make install
  1. nasm
cd ~
wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-${NASM_VERSION}.tar.xz \
    && tar -xvJf nasm-${NASM_VERSION}.tar.xz \
    && cd nasm-${NASM_VERSION} \
    && ./configure --disable-shared --enable-static \
    && make -j8 \
    && sudo make install
  1. x264
cd ~
git clone https://code.videolan.org/videolan/x264.git \
    && cd x264 \
    && git checkout -b stable origin/stable \
    && git pull --rebase \
    && ./configure --enable-pic --enable-shared --disable-asm \
    && make -j8 \
    && sudo make install \
    && export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
  1. x265
cd ~
wget https://github.com/videolan/x265/archive/Release_${X265_VERSION}.tar.gz  \
    && tar zxvf Release_${X265_VERSION}.tar.gz \
    && cd x265-Release_${X265_VERSION}/build/linux \
    && cmake ../../source \
    && make -j8 \
    && sudo make install \
    && export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
  1. FFmpeg
cd ~
git clone https://gitee.com/xia-chu/FFmpeg.git \
    && cd FFmpeg \
    && export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH \
    && ./configure \
        --disable-debug \
        --disable-doc  \
        --disable-shared  \
        --enable-gpl \
        --enable-version3 \
        --enable-static \
        --enable-nonfree \
        --enable-pthreads \
        --enable-libx264 \
        --enable-libx265 \
        --enable-small \
        --pkgconfigdir=/usr/local/lib/pkgconfig \
	    --pkg-config-flags="--static" \
    && make -j8 \
    && sudo make install
  1. libsrtp
cd ~
git clone https://gitee.com/mirrors/libsrtp.git && cd libsrtp && git checkout v2.2.0 && \
        ./configure && make && sudo make install

编译ZLMediaKit(不启用webrtc)

 cd ~ \
    && git clone https://github.com/xia-chu/ZLMediaKit.git \
    && cd ZLMediaKit \
    && git submodule update --init \
    && mkdir -p build release/linux/Release/ \
    && cd build \
    && cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_WEBRTC=false -DENABLE_TESTS=false .. \
    && make -j8

编译ZLMediaKit(启用webrtc)

编译安装openssl
见 在x86平台编译安装openssl
安装libsrtp

git clone https://gitee.com/mirrors/libsrtp.git && cd libsrtp && git checkout v2.3.0 
./configure --enable-openssl --with-openssl-dir=/usr/local/openssl
make && sudo make install
git clone https://github.com/xia-chu/ZLMediaKit.git
cd ZLMediaKit
git submodule update --init
mkdir -p build release/linux/Release/
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_WEBRTC=true -DENABLE_TESTS=false -DENABLE_WEBRTC=true  -DOPENSSL_ROOT_DIR=/usr/local/openssl  -DOPENSSL_LIBRARIES=/usr/local/openssl/lib
cmake --build . --target MediaServer

配置动态库环境

sudo echo "/usr/local/lib/" >>/etc/ld.so.conf.d/zlm.conf
sudo ldconfig -v

本人可接wvp+zlm调试

你可能感兴趣的:(运维,运维)