liblinphone移植

设置编译环境

此步骤笔者为了方便移植管理,仅供参考

创建builddir/build.sh,builddir目录存储编译后的相关文件,build.sh是具体的编译脚本

mkdir -p builddir && touch builddir/build.sh

build.sh内容模板,读者根据情况进行配置,不同的依赖库的配置只需修改cmake相关配置部分即可

rm CMakeFiles/ -r
rm CMakeCache.txt -f
#编译工具
COMPILER_CC=gcc
#编译选项
COMPILER_FLAGS="-fPIC"
#安装位置
COMPILER_PREFIX=$(pwd)/../../install/
#依赖库位置
COMPILER_LIB=$(pwd)/../../install/

#设置相关配置,如关闭相关依赖,主要修改点
cmake -DCMAKE_INSTALL_PREFIX=$COMPILER_PREFIX \
      -DCMAKE_C_FLAGS="$COMPILER_FLAGS" \
      -DCMAKE_C_COMPILER=$COMPILER_CC \
      ..

make clean
make
make install

移植相关依赖

提示!!!编译中遇到错误可以参考错误处理

1.mbedtls

下载

git clone https://github.com/Mbed-TLS/mbedtls.git
#`github`若下载失败可到`gitee`下载

进入mbedtls设置编译环境,执行build.sh

2.BcToolbox

git clone https://gitlab.linphone.org/BC/public/bctoolbox.git

进入BcToolbox设置编译环境,修改cmake配置执行build.sh

#笔者用不到BCUnit依赖库,因此关闭次配置
-DENABLE_TESTS_COMPONENT=OFF \

当关闭ENABLE_TESTS_COMPONENT配置时,需要关闭BCToolboxConfig.cmake文件中对BCUnit依赖项的查找与管理,具体操作如下,find_dependency(BCUnit)的时候添加判断即可,否则在后续编译belr库中会因找不到BCUnit依赖而报错

if(ENABLE_TESTS_COMPONENT)
find_dependency(BCUnit)
endif()

3.belr

git clone https://gitlab.linphone.org/BC/public/belr.git

进入belr设置编译环境,修改cmake配置执行build.sh

-DENABLE_UNIT_TESTS=OFF \

这里需要注意,笔者在BcToolbox中关闭了TESTS的配置,而belrTESTS实现中依赖该配置,因此编译belr时也需要关闭TESTS后续的依赖库也是如此

4.belle-sip

git clone https://gitlab.linphone.org/BC/public/belle-sip.git

进入belle-sip设置编译环境,修改cmake配置执行build.sh

-DENABLE_UNIT_TESTS=OFF \

5.belcard

git clone https://gitlab.linphone.org/BC/public/belcard.git

进入belcard设置编译环境,修改cmake配置执行build.sh

-DENABLE_UNIT_TESTS=OFF \

6.ortp

git clone https://gitlab.linphone.org/BC/public/ortp.git

进入ortp设置编译环境,修改cmake配置执行build.sh

-DENABLE_UNIT_TESTS=OFF \

7.mediastreamer2

git clone https://gitlab.linphone.org/BC/public/mediastreamer2.git

进入mediastreamer2设置编译环境,修改cmake配置执行build.sh

      -DENABLE_UNIT_TESTS=OFF \
      -DENABLE_SRTP=OFF \
      -DENABLE_SPEEX_CODEC=OFF \
      -DENABLE_SPEEX_DSP=OFF \
      -DENABLE_FFMPEG=OFF \
      -DENABLE_V4L=OFF \

8.bzrtp

git clone https://gitlab.linphone.org/BC/public/bzrtp.git

进入bzrtp设置编译环境,修改cmake配置执行build.sh

-DENABLE_UNIT_TESTS=OFF \
-DENABLE_ZIDCACHE=OFF \

9.liblinphone

git clone https://gitlab.linphone.org/BC/public/liblinphone.git

进入liblinphone设置编译环境,修改cmake配置执行build.sh

      -DENABLE_UNIT_TESTS=OFF \
      -DENABLE_ADVANCED_IM=OFF \
      -DENABLE_SQLITE=OFF \
      -DENABLE_XML2=OFF \
      -DENABLE_DB_STORAGE=OFF \
      -DENABLE_LIME_X3DH=OFF \
      -DENABLE_DOC=OFF \
      -DENABLE_CXX_WRAPPER=OFF \
      -DENABLE_FLEXIAPI=OFF \
      -DENABLE_QRCODE=OFF \

编译完成

liblinphone编译完成会在builddir目录下生成daemon文件,PC端运行linphone-daemon执行程序

root@link-virtual-machine:/home/share/linphone/liblinphone/builddir/daemon# ./linphone-daemon
2024-03-31 22:02:58:951 liblinphone-error- Could not find a suitable soundcard with capabilities : 2
2024-03-31 22:02:58:951 liblinphone-error- Could not find a suitable soundcard with capabilities : 2
2024-03-31 22:02:58:951 liblinphone-error- Could not find a suitable soundcard with capabilities : 1
2024-03-31 22:02:58:951 liblinphone-error- Could not find a suitable soundcard with capabilities : 2

当用linphone手机端输入sip:tommy@ip即可呼通PC端,liblinphone移植完毕

Event-type: call-state-changed

Event: LinphoneCallIncomingReceived
From: "Linphone Android" <sip:linphone.android@10.0.0.102>
Id: 1


错误处理

1.CMake Error at CMakeLists.txt:350 (message)

注意,笔者不需要关于声音编解码的第三方依赖库,因此将所有关于声音编解码的库关闭,只保留声音开启使能,但会编译报错,只需要将报错提示修改为警告即可编译通过

message(WARNING "Could not find a support sound driver API. Use -DENABLE_SOUND=NO if you don't care about having sound.")

2.unused parameter

方法1

CMakeLists.txt中,找到-Werror=unused-but-set-variable-Weeor这样的编译选项并将其去除,这样可以避免因为未使用的变量而产生的警告

方法 2

添加下面代码

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}   -w")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}   -w")

3.conflicting declaration of C function

将函数定义修改跟函数声明一致即可

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值