• Ubuntu安装freeSwitch


        在Ubuntu(虚拟机)上多次使用源码方式安装freeSwitch软件,由于freeSwitch在编译中依赖很多软件和工具,再加上系统版本和软件源的原因,每一次安装都遇到很多问题,花费大量时间排查,因此,本文记录一下安装过程和一些问题的解决方法。

    注:文中使用操作系统版本Ubuntu 22.04.1(虚拟机),其它版本操作系统安装流程和问题解决方法类似。

    一、环境安装

    1.安装常用包

    sudo apt install autoconf libtool-bin g++ pkg-config libtiff-dev
    2. 安装libtiff-dev
    sudo apt install libtiff-dev

    3. 安装spandsp
    # git clone https://github.com/freeswitch/spandsp.git
    # cd spandsp
    # ./bootstrap.sh -j
    # ./configure
    # make
    # sudo make install
    # ldconfig


    4. 安装sofia-sip
    no usable sofia-sip; please install sofia-sip-ua devel package or equivalent
    # git clone https://github.com/freeswitch/sofia-sip.git
    #cd sofia-sip
    # ./bootstrap.sh -j
    # ./configure
    # make
    # make install0
    # ldconfig


    5. 安装sqlite3
    解决方法: sudo apt install libsqlite3-dev
              sudo apt install sqlite3

    6. 安装libcurl
    sudo apt install libcurl4-nss-dev

    7. 安装pcre
    sudo apt install libpcre3-dev

    8. 安装speexdsp
    sudo apt install libspeexdsp-dev

    9. 安装libldns
    sudo apt install libldns-dev 

    10. install libks or disable mod_verto in modules.conf
    禁用mod_verto

    11. install libks or disable mod_signalwire
    禁用mod_signalwire

    12. 安装libedit-dev
    sudo apt install libedit-dev

    13. 安装yasm
    sudo apt install yasm

    14. 安装uuid和uuid-dev
    sudo apt install uuid
    sudo apt install uuid-dev

    默认安装后,uuid.h 在/usr/include/linux/目录下,而freeswitch源码引用目录是uuid, 因此需要建立/usr/include/uuid目录

    $mkdir /usr/include/uuid
    $cp /usr/include/linux/uuid.h /usr/include/uuid/

    15. apt install libopus-dev

    16. sudo apt install libsndfile-dev

    二、下载编译

    2.1 下载源码
    方式一:  github下载
    freeSwitch源码下载地址:https://github.com/signalwire/freeswitch
    git clone https://github.com/signalwire/freeswitch

    注:使用git下载可能会出现异常中断,可以在网页上使用zip包下载的方式

    方式二: 文件服务网站下载
    也可以通过下面的网站下载源码
     http://files.freeswitch.org/releases/freeswitch/
     
    方式三:  其它下载方式(如gitee等)

    2.2 编译
    步骤1: sudo ./bootstrap.sh

    步骤2:sudo ./configure

    步骤3:sudo make
       

     编译错误处理:
       1. -Werror=implicit-function-declaration错误
           示例:src/switch_apr.c:1134:9: error: implicit declaration of function ‘uuid_unparse_lower’ [-Werror=implicit-function-declaration]
            解决方法: 修改Makefile中CFLAGS一行,忽略错误
               CFLAGS = -g -O2 -Wno-error=implicit-function-declaration 

      2. -Werror=deprecated-declarations错误
      解决方法: 修改Makefile中CFLAGS一行,忽略错误
      CFLAGS = -g -O2 -Wno-error=implicit-function-declaration -Wno-error=deprecated-declarations

      3. -Werror=pedantic错误
      解决方法: 修改Makefile中CFLAGS一行,忽略错误
      CFLAGS = -g -O2 -Wno-error=implicit-function-declaration -Wno-error=deprecated-declarations
      
      4. 禁用一些模块
         比如mode_lua、mod_opus、mod_pgsql、mod_skinny等
         
    2.3 安装:
        $ sudo make install

    默认安装目录:/usr/local/freeswitch
    voip@voip-virtual-machine:/usr/local/freeswitch$ tree -L 1
    .
    ├── bin
    ├── conf
    ├── db
    ├── fonts
    ├── grammar
    ├── htdocs
    ├── images
    ├── include
    ├── lib
    ├── log
    ├── mod
    ├── recordings
    ├── run
    └── scripts

    2.4 启动freeswitch
    进入到安装目录,启动程序。也可以在其它目录使用绝对路径启动
    voip@voip-virtual-machine:/usr/local/freeswitch$ ./bin/freeswitch

    2.5 终端注册
    使用sip终端注册已有账号1000(默认密码1234,默认端口5060)成功。如果一切正常,那么恭喜你,你已经完成基本的安装了。

    三、安装问题的解决思路

    一般是软件或库找不到,有三种解决方法
    1. 使用apt install安装
    2. 从github或gitee上下载源码进行编译安装

    注:freeswitch可以通过编辑module.conf文件禁用相关模块

    四、安装过程中遇到的问题及解决方法

    • 1. build-requirements: autoconf not found.

    解决方法: sudo apt install autoconf

    • 2. build-requirements: libtool not found.

    解决方法: sudo apt install libtool-bin

    • 3. 缺少spandsp

    # git clone https://github.com/freeswitch/spandsp.git
    # cd spandsp
    # ./bootstrap.sh -j
    # ./configure
    # make
    # make install
    # ldconfig

    • 4.缺少sofia-sip

    no usable sofia-sip; please install sofia-sip-ua devel package or equivalent
    # git clone https://github.com/freeswitch/sofia-sip.git
    #cd sofia-sip
    # ./bootstrap.sh -j
    # ./configure
    # make
    # make install
    # ldconfig

    • 5. fatal error: openssl/ssl.h: No such file or directory

    解决方法: sudo apt install libssl-dev

    • 6. Package sqlite3 was not found

    解决方法: sudo apt install libsqlite3-dev
                     sudo apt install sqlite3

    • 7. libcurl was not found

           解决方法: sudo apt install libcurl4-nss-dev

    • 8. Package libpcre was not found 

             解决方法: sudo apt install libpcre3-dev

    • 9. Package speex was not found 

                 sudo apt install libspeexdsp-dev

    • 10. You need to either install libldns-dev or disable mod_enum in modules.conf

              解决方法: sudo apt install libldns-dev 

    • 11. You need to either install libks or disable mod_verto in modules.conf

                方法一:下载安装 https://github.com/signalwire/libks.git

                方法二:禁用mod_verto
                      sudo vim modules.conf 
                      #endpoints/mod_verto

    • 12. error: You need to either install libedit-dev

                    解决方法: sudo apt install libedit-dev

    • 13. 缺少yasm

                     解决方法: sudo apt install yasm

    • 14. You need to either install signalwire-client-c

                    方法一:下载编译安装: https://github.com/signalwire/signalwire-c.git

                    方法二: 注释掉modules.conf中的signalwire模块

    • 15. 编译错误

                    ./include/apr_general.h:33:14: error: ‘__DARWIN_NSIG’ undeclared here (not in a function)
                    33 | #define NSIG __DARWIN_NSIG
    注: 没找到原因,发现没有代码使用该定,直接将该行定义注释掉

    • 16. 接口过期编译错误

    错误1:

    In file included from src/switch_apr.c:79:
    /usr/include/openssl/md5.h:49:27: note: declared here
       49 | OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
          |                           ^~~~~~~~
    src/switch_apr.c:1177:9: warning: ‘MD5_Update’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
     1177 |         MD5_Update(&md5_context, input, inputLen);

    解决方法:关闭接口过期警告

                   sudo vim Makefile
                  CFLAGS = -g -O2 -Wno-error=deprecated-declarations

    错误2:

    skinny_protocol.c:685:65: error: array subscript ‘skinny_message_t {aka struct skinny_message}[0]’ is partly outside array bounds of ‘unsigned char[292]’ [-Werror=array-bounds]
    CFLAGS = -g -O2 -Wno-error=deprecated-declarations -Wno-error=array-bounds

    解决方法:关闭相应告警

                   sudo vim Makefile
                  CFLAGS = -g -O2  -Wno-error=array-bounds

    • 17. 没有libavformat-dev and libswscale-dev

    Makefile:1481: *** You must install libavformat-dev and libswscale-dev to build mod_av.  Stop.

    解决方法:
    sudo apt install libavformat-dev
    sudo apt install libswscale-dev

    注: 如果编译时还提示找不到,需要重新执行sudo ./configure

    • 18 缺少libtiff

    configure: error: "Cannot build without libtiff (does your system require a libtiff-devel package?)"

    解决方法:sudo apt install libtiff-dev

    • 19 缺少uuid

    src/switch_apr.c:81:10: fatal error: uuid/uuid.h: No such file or directory

    解决方法:

     sudo apt install uuid

     如果依旧找不到,查看 一下uuid.h文件的位置, 在笔者环境中,如下

    $ ls /usr/include/linux/uuid.h 
    /usr/include/linux/uuid.h

    可以看出uuid.h在linux目录下,只要相应的创建/usr/lnclude/uuid目录,并将linux/uuid.h拷贝过去可以了

    • 20 找不到uuid_xx函数

    /usr/bin/ld: ./.libs/libfreeswitch.so: undefined reference to `uuid_parse'
    /usr/bin/ld: ./.libs/libfreeswitch.so: undefined reference to `uuid_unparse_lower'
    /usr/bin/ld: ./.libs/libfreeswitch.so: undefined reference to `uuid_generate'

    解决方法:sudo apt install uuid-dev

  • 相关阅读:
    Allegro172版本DFM功能介绍
    Django之csrf与auth模块操作
    PHP 变量
    midway的使用教程
    微信网页支付小白指南-域内浏览器支付 + 外部浏览器支付
    基于python的pulp库使用,从基础模型到复杂模型,从一维变量到二维变量
    老杨说运维 | 非常重要,事关转型
    NP9 十六进制数字的大小牛客网python答案(已测试通过)
    python中的accumulate()函数
    点云入门知识
  • 原文地址:https://blog.csdn.net/szkbsgy/article/details/126431526