記錄一次在尤拉(openEuler22.03LTS-SP4)系統下安裝(踩坑)Freeswitch1.10.11的全過程

CyunZing發表於2024-07-18

目錄
  • 前言
  • 安裝環境
  • 1. 下載Freeswitch
    • 1.1 git clone 下載freeswitch庫
    • 1.2 官網下載
  • 2. 開始安裝前的工作
    • 2.1 安裝編譯時需要的環境【先安裝這個!】
    • 2.2 configure前需要安裝的庫
      • 2.2.1. spandsp
      • 2.2.2. sofia-sip
      • 2.2.3. libks
      • 2.2.4. signalwire-c
      • 2.2.5 x264
      • 2.2.6. libav
        • 2.2.6.1 可能出現的錯誤一
        • 解決方法
        • 2.2.6.2 可能出現的錯誤二
        • 解決方法
      • 2.2.7. opus
  • 3. 檢查Freeswitch編譯環境
    • 3.1 出現問題以及解決方法
      • 3.1.1. checking for spandsp >= 3.0... configure: error: no usable spandsp; please install spandsp3 devel package or equivalent
      • 3.1.2. configure: error: You need to either install libldns-dev or disable mod_enum in modules.conf
      • 3.1.2. configure: error: You need to either install libedit-dev (>= 2.11) or configure with --disable-core-libedit-support
      • 如遇此類問題
  • 4. 編譯Freeswitch
    • 4.1 暫時遮蔽了mod_av、mod_lua
      • 問題1、mod_av編譯時報錯libswresample/swresample.h: No such file or directory
    • 4.2 編譯安裝
    • 4.3 驗證安裝
  • 5. Freeswitch 啟動!

前言

Centos7.x系統已於2024年6月30日起停止維護更新,如此這般隨著時間的推移,系統可能會出現越來越多的故障和漏洞問題等,這就會導致作業系統會暴露在網路攻擊的威脅之下。

這就不得不迫使我轉移學習資料和專案到更新的版本或者其他的作業系統。在當今國產化的浪潮中,我選擇了由華為主導的openEuler作業系統。原因如下:

  1. 擁有活躍的開源社群支援
    • 活躍社群:openEuler擁有一個活躍的開源社群,眾多企業和開發者參與其中,共同促進技術的進步和生態的繁榮。
    • 持續更新:得益於社群的貢獻,也能夠持續獲得更新,包括功能增強、效能最佳化和安全補丁。
  2. 擁有強大的相容性與生態支援
    • 相容性強:具有良好的相容性,能夠很好的相容Centos 7遷移過來的專案和支援多種硬體架構和軟體應用。
    • 豐富的生態:華為與眾多軟硬體廠商合作,構建了較為完善的生態系統。

基於以上的原因以及還未列出的原因,openEuler作業系統是可以滿足我的需求的。

安裝環境

作業系統 處理器 硬碟大小 記憶體大小
openEuler 22.03 LTS-SP4 J4125 120G 8G

image

1. 下載Freeswitch

1.1 git clone 下載freeswitch庫

[root@localhost data]# git clone https://github.com/signalwire/freeswitch.git
正克隆到 'freeswitch'...
remote: Enumerating objects: 321005, done.
remote: Counting objects: 100% (553/553), done.
remote: Compressing objects: 100% (372/372), done.
remote: Total 321005 (delta 288), reused 330 (delta 153), pack-reused 320452
接收物件中: 100% (321005/321005), 132.64 MiB | 895.00 KiB/s, done.
處理 delta 中: 100% (250772/250772), done.

1.2 官網下載

curl -o freeswitch-1.10.11.-release.tar.gz https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.11.-release.tar.gz

2. 開始安裝前的工作

2.1 安裝編譯時需要的環境【先安裝這個!】

yum -y install tar gcc-c++ nasm yasm make libtool libtool-devel uuid-devel libtiff-devel libjpeg-devel cmake libuuid-devel libatomic sqlite-devel libcurl libcurl-devel pcre pcre-devel speex speex-devel speexdsp speexdsp-devel ldns-devel libedit-devel libsndfile-devel

2.2 configure前需要安裝的庫

freeswitch官方把spandspsofia-sip從FreeSWITCH程式碼倉庫單獨弄出來了,所以編譯前要單獨編譯安裝。

2.2.1. spandsp

這個我真是踩了大坑,由於spandsp一直在更新,所以要用一個穩定版本才行。

git clone https://github.com/freeswitch/spandsp.git
cd spandsp/
git checkout e1e33ecd2b6325fc4f2542da2184c834fa77c5c8
./bootstrap.sh
./configure
make -j$(nproc) && make install

vi /etc/profile
# 文末新增以下內容:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
source /etc/profile

2.2.2. sofia-sip

git clone https://github.com/freeswitch/sofia-sip.git
cd sofia-sip
./bootstrap.sh
./configure
make -j$(nproc) && make install

2.2.3. libks

git clone https://github.com/signalwire/libks.git
cd libks
cmake .
make -j$(nproc) && make install

這裡有個坑,要將libks2.pc連結或者複製到前面spandsp設定的PKG_CONFIG_PATH中的目錄裡面去,要不然下面signalwire-c會報錯 Package 'libks2', required by 'virtual:world', not found

find /usr -name 'libks2.pc' # 如果不知道libks2.pc的路徑就搜尋。
ln -sf /usr/lib/pkgconfig/libks2.pc /usr/local/lib/pkgconfig/libks2.pc

2.2.4. signalwire-c

git clone https://github.com/signalwire/signalwire-c.git
cd signalwire-c/
cmake .
make -j$(nproc) && make install
# find /usr -name 'signalwire_client2.pc' # 如果不知道路徑就搜尋。

2.2.5 x264

git clone https://git.videolan.org/git/x264.git
cd x264
./configure --enable-shared --enable-static --disable-opencl
make -j$(nproc) && make install
cp /usr/local/lib/pkgconfig/x264.pc /usr/lib64/pkgconfig

2.2.6. libav

git clone https://github.com/libav/libav.git
cd libav
git checkout v12.3
./configure --enable-pic --enable-shared  --enable-libx264 --enable-gpl --extra-libs="-ldl"
make -j$(nproc) && make install
cp /usr/local/lib/pkgconfig/libavcodec.pc    /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavdevice.pc   /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavfilter.pc   /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavformat.pc   /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavresample.pc /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libavutil.pc     /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/libswscale.pc    /usr/lib64/pkgconfig/
ldconfig # 切記,複製完一定要執行重新整理
2.2.6.1 可能出現的錯誤一
libavcodec/libx264.c: 在函式‘X264_frame’中:
libavcodec/libx264.c:142:9: 錯誤:‘x264_bit_depth’未宣告(在此函式內第一次使用)
  142 |     if (x264_bit_depth > 8)
      |         ^~~~~~~~~~~~~~
libavcodec/libx264.c:142:9: 附註:每個未宣告的識別符號在其出現的函式內只報告一次
libavcodec/libx264.c: 在函式‘X264_init_static’中:
libavcodec/libx264.c:577:9: 錯誤:‘x264_bit_depth’未宣告(在此函式內第一次使用)
  577 |     if (x264_bit_depth == 8)
      |         ^~~~~~~~~~~~~~
make: *** [Makefile:44:libavcodec/libx264.o] 錯誤 1
make: *** 正在等待未完成的任務....

img

解決方法
sed -i 's/x264_bit_depth/X264_BIT_DEPTH/g' libavcodec/libx264.c
2.2.6.2 可能出現的錯誤二

這裡有個坑...,當我執行make install時輸出如下。然後我去安裝yasm然後make clean重新跑一下就可以了

INSTALL doc/avconv.1
INSTALL doc/avprobe.1
INSTALL libavdevice/libavdevice.a
make: *** 沒有規則可製作目標“util.asm”,由“libavresample/x86/audio_convert.o” 需求。 停止。
解決方法
yum -y install yasm

2.2.7. opus

git clone https://freeswitch.org/stash/scm/sd/opus.git
# 官方倉庫有問題可以下載第三方映象源http://freeswitch.clx.fun:12130/src-releases/libs/opus-1.1-p2.tar.gz或者去官網https://www.opus-codec.org/downloads/
cd opus
./autogen.sh 
./configure
make -j4 && make install
cp /usr/local/lib/pkgconfig/opus.pc /usr/lib64/pkgconfig

3. 檢查Freeswitch編譯環境

tar zxvf freeswitch-1.10.11.-release.tar.gz
cd freeswitch-1.10.11.-release/
./configure --prefix=/usr/local/freeswitch

這裡我是採用1.2 官網下載的方式下載官網的壓縮包,出現下圖的資料就是檢查完成了。

img

3.1 出現問題以及解決方法

3.1.1. checking for spandsp >= 3.0... configure: error: no usable spandsp; please install spandsp3 devel package or equivalent

檢查2.2.1. spandsp有無安裝失敗

3.1.2. configure: error: You need to either install libldns-dev or disable mod_enum in modules.conf

檢查2.1 安裝編譯時需要的環境有無安裝全

3.1.2. configure: error: You need to either install libedit-dev (>= 2.11) or configure with --disable-core-libedit-support

同上解決方案

如遇此類問題

按理來說執行完2.1 安裝編譯時需要的環境應該就可以了,但是如果還由錯誤,可以截圖留言討論討論。

4. 編譯Freeswitch

4.1 暫時遮蔽了mod_av、mod_lua

會導致編譯不透過,暫時未找到原因【待排查】,嘗試過了安裝ffmpeg和ffmpeg-devel,未果。
2024年7月18日晚下班時分思來想去,這兩個問題不解決我估計今晚都睡不著了,下定決定全力以赴解決它,幸得皇天不負有些人,當然啦,還有我聰明的小腦袋終於解決了,下面是問題的原因和解決的方法。

問題1、mod_av編譯時報錯libswresample/swresample.h: No such file or directory

問題原因:預設安裝的yum -y install ffmpeg ffmpeg-devel標頭檔案在/usr/include/ffmpeg/下,而freeswitch預設是在/usr/local/include/中尋找。
解決方法:將/usr/include/ffmpeg/裡面的資料夾複製到/usr/local/include/即可。

cp -r /usr/include/ffmpeg/lib* /usr/local/include/

在freeswitch-1.10.11.-release/modules.conf下可以選擇需要編譯的mod

4.2 編譯安裝

./configure之後才能執行編譯

cd freeswitch-1.10.11.-release/
make -j$(nproc) && make install

出現下圖這樣就是安裝成功了,接下來就可以開啟Freeswitch之旅了
img

編譯過程中如果遇到以下錯誤可以按照下列方法檢查
You must install libopus-dev to build mod_opus,就執行一遍 2.2.7. opus然後重新./configure

You must install libsndfile-dev to build mod_sndfile,就執行yum安裝libsndfile-devel然後重新./configure

4.3 驗證安裝

將freeswitch和fs_cli連結到/usr/local/bin/,這樣我們就可以直接在命令列輸入命令執行啦。

ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/
ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/

輸入freeswitch -version輸出下面版本號就是正常得了

FreeSWITCH version: 1.10.11-release~64bit (-release 64bit)

5. Freeswitch 啟動!

freeswitch -nc # 後臺無console啟動
fs_cli # freeswitch自帶命令列

img

相關文章