0%

Ubuntu16.04 源码编译安装freeswitch

在Multimedia的lab2需要我们安装使用freeswitch, 并且因为需要进行视频会议,需要加一些mod,在本机编译安装了freeswitch,总的来说编译安装freeswitch本体还是比较容易的,在编译几个模块的时候碰到一些问题比较麻烦。

源码获取

1
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git

因为我本机在校园网下使用git clone 会报错,所以直接去下载了tar.gz源码包freeswitch-1.8.5,但是后来在寝室测试直接git clone 也可以。git clone 地址:https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse,可以点tag找自己想要的版本

后来因为缺mod,图省事就使用了和助教一样的版本1.6.19。

安装环境依赖

安装编译需要的lib库

1
sudo apt-get -y install build-essential subversion automake autoconf wget libtool libncurses5-dev libspeex-dev libspeexdsp-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev  libldns-dev libedit-dev libssl-dev pkg-config yasm liblua50-dev libopus-dev libsndfile-dev libpq-dev pkg-config lua5.2 lua5.2-doc liblua5.2-dev libreadline-dev

编译安装

编译更多模块

freeswitch可以通过动态加载模块,如果需要编译更多的模块,有两种方法:

  • 编辑freeswitch/modules.conf文件,找到要安装的模块,去掉前面的注释符号#,然后需要重新执行./configure,编译整个freeswitch。
  • 在命令行执行make mod_xxx-install命令,这样就编译相应模块,并把编译后的动态库安装的/usr/local/freeswitch/mod目录下了。

编译安装完以后,

  • 可以通过启动freeswitch后运行load mod_xxx来测试相应模块的编译是否成功。
  • 也可以修改/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml设置freeswitch启动时自动加载的模块。

编译本体

1
2
3
4
5
6
7
8
9
10
11
12
13
# 编译安装
./bootstrap.sh #如果是tar包则省略这一步
./configure
make -j8
sudo make install

# 软连接创建
ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/
ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/

# 安装声音文件
sudo make cd-sounds-install
sudo make cd-moh-install

编译成功以后,运行sudo freeswitch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.=============================================================.
| _____ ______ _____ _____ ____ _ _ |
| | ___| __ ___ ___/ ___\ \ / /_ _|_ _/ ___| | | | |
| | |_ | '__/ _ \/ _ \___ \\ \ /\ / / | | | || | | |_| | |
| | _|| | | __/ __/___) |\ V V / | | | || |___| _ | |
| |_| |_| \___|\___|____/ \_/\_/ |___| |_| \____|_| |_| |
| |
.=============================================================.
| Anthony Minessale II, Michael Jerris, Brian West, Others |
| FreeSWITCH (http://www.freeswitch.org) |
| Paypal Donations Appreciated: paypal@freeswitch.org |
| Brought to you by ClueCon http://www.cluecon.com/ |
.=============================================================.

.===============================================================.
| _ |
| ___| |_ _ ___ ___ ___ _ __ ___ ___ _ __ ___ |
| / __| | | | |/ _ \/ __/ _ \| '_ \ / __/ _ \| '_ ` _ \ |
| | (__| | |_| | __/ (_| (_) | | | | _ | (_| (_) | | | | | | |
| \___|_|\__,_|\___|\___\___/|_| |_| (_) \___\___/|_| |_| |_| |
| |
.===============================================================.
/
2019-05-09 17:15:32.605630 [INFO] switch_core.c:2436
FreeSWITCH Version 1.6.19~64bit ( 64bit)

FreeSWITCH Started
Max Sessions [1000]
Session Rate [30]
SQL [Enabled]

报错及解决

注意:在安装了新的lib之类的修改以后要重新执行./configure

[error1]: fatal error: lua.h

[solution1]

1
2
sudo cp /usr/include/lua5.2/*.h  ./src/mod/languages/mod_lua/
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.2.so /usr/lib/x86_64-linux-gnu/liblua.somake

[error2]: Makefile:930: *** You must install libks to build mod_signalwire.

1
2
3
4
5
6
making all mod_signalwire
make[4]: Entering directory '/home/color/freeswitchls/src/freeswitch/src/mod/applications/mod_signalwire'
Makefile:930: *** You must install libks to build mod_signalwire. Stop.
make[4]: Leaving directory '/home/color/freeswitch/src/freeswitch/src/mod/applications/mod_signalwire'
Makefile:683: recipe for target 'mod_signalwire-all' failed
make: *** [all] Error 2

[solusion2]

安装 libks 和 signalwire

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# libks
git clone https://github.com/signalwire/libks.git
cd libks
/usr/local/bin/cmake .
make
sudo make install
# 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/

其中,安装libks时出现:

1
2
-- Checking for module 'uuid'
-- No package 'uuid' found

需要再手动安装一下uuid

1
sudo apt-get install uuid-dev

[error3]:安装mod_av的时候一直报错

很奇怪的是,这个报错不讲缺什么,讲的是函数接口deprecated,导致弄了挺久才发现要这么干。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
mod_av.c: In function ‘mod_av_shutdown’:
mod_av.c:121:2: error: ‘av_lockmgr_register’ is deprecated [-Werror=deprecated-declarations]
av_lockmgr_register(NULL);
^
In file included from mod_av.c:34:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:6103:5: note: declared here
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
^
mod_av.c: In function ‘mod_av_load’:
mod_av.c:127:2: error: ‘av_lockmgr_register’ is deprecated [-Werror=deprecated-declarations]
av_lockmgr_register(&mod_av_lockmgr_cb);
^
In file included from mod_av.c:34:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:6103:5: note: declared here
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
^
mod_av.c:131:2: error: ‘av_register_all’ is deprecated [-Werror=deprecated-declarations]
av_register_all();
^
In file included from mod_av.c:35:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:2043:6: note: declared here
void av_register_all(void);
^
cc1: all warnings being treated as errors
Makefile:681: recipe for target 'mod_av_la-mod_av.lo' failed
make[4]: *** [mod_av_la-mod_av.lo] Error 1
make[4]: Leaving directory '/opt/freeswitch-1.6.19/src/mod/applications/mod_av'
Makefile:667: recipe for target 'mod_av-all' failed

[solution3]:需要安装libav

1
2
3
4
5
6
7
sudo apt-get install yasm libvpx. libx264. libx264-dev
# install libav
git clone https://freeswitch.org/stash/scm/sd/libav.git
cd libav
./configure --enable-shared --enable-libx264 --enable-gpl
make
sudo make install

[error4]: 安装mod_shout缺包

1
Makefile:932: *** You must install libshout3-dev to build mod_shout。 停止。
1
sudo apt-get install libshout3-dev
1
Makefile:927: *** You must install libmpg123-dev to build mod_shout。 停止。
1
sudo apt-get install libmpg123-dev
1
Makefile:922: *** You must install libmp3lame-dev to build mod_shout。 停止。
1
sudo apt-get install libmp3lame-dev

[error5]: You must install libilbc-dev to build mod_ilbc

[solution5]

1
2
3
4
5
6
# install libilbc 因为apt包里没有libilbc-dev
git clone https://freeswitch.org/stash/scm/sd/libilbc.git
./bootstrap.sh
./configure
make -j8
make install

验证安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
sparta:~$ sudo freeswitch 
2019-05-13 13:55:15.895884 [INFO] switch_event.c:685 Activate Eventing Engine.
......
2019-05-13 13:55:36.037369 [CONSOLE] switch_core.c:2427
.=============================================================.
| _____ ______ _____ _____ ____ _ _ |
| | ___| __ ___ ___/ ___\ \ / /_ _|_ _/ ___| | | | |
| | |_ | '__/ _ \/ _ \___ \\ \ /\ / / | | | || | | |_| | |
| | _|| | | __/ __/___) |\ V V / | | | || |___| _ | |
| |_| |_| \___|\___|____/ \_/\_/ |___| |_| \____|_| |_| |
| |
.=============================================================.
| Anthony Minessale II, Michael Jerris, Brian West, Others |
| FreeSWITCH (http://www.freeswitch.org) |
| Paypal Donations Appreciated: paypal@freeswitch.org |
| Brought to you by ClueCon http://www.cluecon.com/ |
.=============================================================.

.===============================================================.
| _ |
| ___| |_ _ ___ ___ ___ _ __ ___ ___ _ __ ___ |
| / __| | | | |/ _ \/ __/ _ \| '_ \ / __/ _ \| '_ ` _ \ |
| | (__| | |_| | __/ (_| (_) | | | | _ | (_| (_) | | | | | | |
| \___|_|\__,_|\___|\___\___/|_| |_| (_) \___\___/|_| |_| |_| |
| |
.===============================================================.

2019-05-13 13:55:36.037382 [INFO] switch_core.c:2436
FreeSWITCH Version 1.6.19~64bit ( 64bit)

FreeSWITCH Started
Max Sessions [1000]
Session Rate [30]
SQL [Enabled]
1
2

### freeswitch 默认号码说明

9999 | 保持音乐
9996 | echo,回音测试
9992 | info,在控制台上显示呼叫参数
9888 | FreeSWITCH电话会议,每周召开
5900 | 呼叫挂起
5901 | 接听挂起的呼叫
5000 | 示例IVR
4000 | 听取语音信箱
33xx | 电话会议,48K(其中xx可为00-99,下同)
32xx | 电话会议,32K
31xx | 电话会议,16K
30xx | 电话会议,8K
2000-2002 | 呼叫组
1000-1019 | 默认分机号

```

参考


欢迎关注我的其它发布渠道