前言
freswitch在centos7下编译总体上还是步骤比较复杂的。
忠告
千万别使用 CentOS 部署 FreeSWITCH !!!
以下大部分都是笔者用 CentOS7 自编译踩得坑。
建议直接 Debian 安装官方编译好的包!!!可以少踩很多坑(严重怀疑官方歧视 CentOS)。
一、环境
centos 7.9
freeswitch 1.10.9
安装高版本cmake
wget https://github.com/Kitware/CMake/releases/download/v3.23.0/cmake-3.23.0.tar.gztar -zvxf cmake-3.23.0.tar.gzcd cmake-3.23.0./bootstrap //编译make //安装make install
链接
sudo ln -sf /usr/local/bin/cmake /usr/bin/cmake
sudo ln -sf /usr/local/bin/cpack /usr/bin/cpack
sudo ln -sf /usr/local/bin/ctest /usr/bin/ctest
二、下载源码
freeswitch下载地址: https://github.com/signalwire/freeswitch.git
另外有两个比较重新的库需要手动安装,分别是spandsp和sofia-sip
下载命令:
cd /data
git clone -b v1.10.9 https://github.com/signalwire/freeswitch
cd /data/freeswitch
git clone https://github.com/freeswitch/spandsp.git
git clone https://github.com/freeswitch/sofia-sip.git
三、编译
.安装 epel扩展和文件传输工具lrzsz
yum install -y epel-release lrzsz
.安装yasm
yum -y install yasm
1. 编译必需库
首先,要先编译spandsp和sofia-sip, 否则freeswitch在configure阶段会报错。
#编译spandsp
cd /data/freeswitch/spandsp
./bootstrap.sh
./configure
make
make install
#编译sofia-sip
cd /data/freeswitch/sofia-sip
./bootstrap.sh
./configure
make
make install
#添加库的路径到系统
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
ldconfig
2. 修改module.conf
下面则是安装freeswitch, 由于freeswitch支持动态编译和动态加载,一些不需要的模块可以不编译,如:mod_signalwire、mod_av,修改方法:
找到module.conf文件,找到mod_signalwire和mod_av注释掉,修改如下:
#applications/mod_signalwire
#applications/mod_av
3. 编译freeswitch
有了前两步的准备,编译freeswitch基本就不会遇到问题了,命令如下:
cd /data/freeswitch
./bootstrap.sh
./configure --enable-portable-binary --prefix=/usr/local/freeswitch --with-gnu-ld --with-python --with-openssl --enable-core-odbc-support --enable-zrtp
make
make install
编译完成后,会出现下面信息:
****************************** REPORT ******************************UniMRCP version............... : 1.2.0APR version................... : 1.2.8
APR-util version.............. : 1.2.8
Sofia-SIP version............. : 1.13.15Compiler...................... : gcc
Compiler flags................ : -g -O2 -pthread
Preprocessor definitions...... : -D_REENTRANT -D_GNU_SOURCE
Linker flags.................. : -L/home1/irteam/freeswitch/libs/apr-util/xml/expat/libUniMRCP client lib............ : yes
Sample UniMRCP client app..... : yes
Sample UMC C++ client app..... : yes
Misc ASR client lib and app... : yesUniMRCP server lib............ : yes
UniMRCP server app............ : yesDemo synthesizer plugin....... : yes
Demo recognizer plugin........ : yes
Demo verifier plugin.......... : yes
Recorder plugin............... : yesInstallation layout........... : classic
Installation directory........ : /usr/local/freeswitch********************************************************************-------------------------- FreeSWITCH configuration --------------------------Locations:prefix: /usr/local/freeswitchexec_prefix: /usr/local/freeswitchbindir: ${exec_prefix}/binconfdir: /usr/local/freeswitch/conflibdir: ${exec_prefix}/libdatadir: /usr/local/freeswitchlocalstatedir: /usr/local/freeswitchincludedir: /usr/local/freeswitch/include/freeswitchcertsdir: /usr/local/freeswitch/certsdbdir: /usr/local/freeswitch/dbgrammardir: /usr/local/freeswitch/grammarhtdocsdir: /usr/local/freeswitch/htdocsfontsdir: /usr/local/freeswitch/fontslogfiledir: /usr/local/freeswitch/logmodulesdir: /usr/local/freeswitch/modpkgconfigdir: ${exec_prefix}/lib/pkgconfigrecordingsdir: /usr/local/freeswitch/recordingsimagesdir: /usr/local/freeswitch/imagesruntimedir: /usr/local/freeswitch/runscriptdir: /usr/local/freeswitch/scriptssoundsdir: /usr/local/freeswitch/soundsstoragedir: /usr/local/freeswitch/storagecachedir: /usr/local/freeswitch/cache
四 ./configure编译问题解决
执行./configure,做相关编译前的环境检查,错误处理如下:
4.1 安装pcre
checking for libpcre >= 7.8... Package libpcre was not found in the pkg-config search path. Perhaps you should add the directory containing `libpcre.pc' to the PKG_CONFIG_PATH environment variable No package 'libpcre' found
configure: error: Library requirements (libpcre >= 7.8) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.
少包,执行:
yum install pcre
yum install pcre-devel解决
4.2 安装speex
checking for speex >= 1.2rc1 speexdsp >= 1.2rc1... Package speex was not found in the pkg-config search path. Perhaps you should add the directory containing `speex.pc' to the PKG_CONFIG_PATH environment variable No package 'speex' found Package speexdsp was not found in the pkg-config search path. Perhaps you should add the directory containing `speexdsp.pc' to the PKG_CONFIG_PATH environment variable No package 'speexdsp' found
configure: error: Library requirements (speex >= 1.2rc1 speexdsp >= 1.2rc1) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.
执行:
yum install speex
yum install speex-devel
4.3 屏蔽libldns
checking for libldns >= 1.6.6... checking for ldns_str2rdf_a in -lldns... no
configure: error: You need to either install libldns-dev or disable mod_enum in modules.conf
vi modules.conf
#applications/mod_enum
4.4 安装libedit-dev
configure: error: You need to either install libedit-dev (>= 2.11) or configure with --disable-core-libedit-support
yum install libedit-devel
4.5、安装sounds声音文件
make sounds-install
make moh-install
4.6、注释掉mod_av
making all mod_av
make[4]: Entering directory `/freeswitch/src/mod/applications/mod_av'
Makefile:1442: *** You must install libavformat-dev and libswscale-dev to build mod_av. Stop.
make[4]: Leaving directory `/freeswitch/src/mod/applications/mod_av'
vi modules.conf
#applications/mod_av
或者安装
wget https://libav.org/releases/libav-12.3.tar.gz
注意,版本必须是12.3的版本,不然报错
avformat.c: In function 'no_video_decode_packets':
avformat.c:2464:59: error: 'AVStream {aka struct AVStream}' has no member named 'codecpar'; did you mean 'codec'?
switch_packetizer_feed_extradata(context->packetizer, st->codecpar->extradata, st->codecpar->extradata_size);
这是你的libav版本不对,你要用12.3的版本,之后的版本去掉了codec的指针,用了新的接口,对应mod_av不兼容。要么修改mod_av的源码把对应函数换成最新的,要么使用12.3的版本
另外,听说可以安装ffmpeg-devel,没有尝试
直接用 Debian 系统安装 FreeSWITCH ,不需要自己苦逼的编译安装
mod_av 需要 libavformat-dev,但 CentOS 没有,通过第三方 yum 库安装 ffmpeg-devel 包实现(yum 的 FreeSWITCH 版本里面是没有 mod_av、mod_b64、mod_png 的,所以上面的安装也就没有):
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum install -y ffmpeg-devel
4.7、注释掉mod_lua
make[4]: Entering directory `//freeswitch/src/mod/languages/mod_lua'
CXX mod_lua_la-mod_lua.lo
mod_lua.cpp:37:17: fatal error: lua.h: No such file or directory
#include "lua.h"
#languages/mod_lua
4.8、安装opus-devel
错误提示:You must install libopus-dev to build mod_opus
yum -y install opus-devel
如果还是报这个错误,在 Makefile 就注释这两行,暂时直接屏蔽,待确认:
# 大概是在第 896、897 行
vim freeswitch/src/mod/codecs/mod_opus/Makefile#install: error
#all: error
4.9、安装 libks
# libks
git clone https://github.com/signalwire/libks.git
cd libks
/usr/local/bin/cmake .
make
sudo make install
4.10、安装signalwire-c
Makefile:947: *** You must install signalwire-client-c to build mod_signalwire. Stop.
cd /usr/local/src/freeswitch
git clone https://github.com/signalwire/signalwire-c.git
cd signalwire-c
cmake .
make
sudo make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}
sudo ldconfig
ln -sf /usr/local/lib64/pkgconfig/signalwire_client.pc /usr/lib64/pkgconfig/signalwire_client.pc
或者
# signalwire
git clone https://github.com/signalwire/signalwire-c.git
cd signalwire-c
/usr/local/bin/cmake .
make
sudo make install
cp /usr/local/lib/pkgconfig/*.pc /usr/lib/pkgconfig/
cp -f /usr/local/lib/* /usr/lib64/
五、验证
freeswitch安装完成之后,下一步就是启动freeswitch并验证可用性了。
首先
1. 启动freeswitch
cd /usr/local/freeswitch/bin
./freeswitch -nonat
参考
【FreeSwitch开发实践】centos7下编译安装freeswitch及常见编译问题的解决_checking for spandsp >= 3.0... configure: error: n_一马途追的博客-CSDN博客