概述
GB28181 SIP开发环境搭建
- 一、sip开源库
- 1、osip2和eXosip2
- 2、PJSIP
- 二、开发环境搭建
- 1.下载软件
- 2.编译安装osip2
- 2.1解决报错
- 2.2编译
- 3.编译安装exosip2
- 3.1编译报错
- 3.2编译
一、sip开源库
1、osip2和eXosip2
作为SIP
客户端的开发协议栈
osip2:
文档地址:https://www.gnu.org/software/osip/
源码地址:http://ftp.gnu.org/gnu/osip/
eXosip2:
文档地址: http://www.antisip.com/documentation/exosip2/modules.html
源码地址:http://download.savannah.gnu.org/releases/exosip/
2、PJSIP
作为SIP
服务端开发库
https://www.pjsip.org/download.htm
二、开发环境搭建
1.下载软件
下载:
libosip2-5.2.1
下载:
pthreads-w32-2-9-1-release
下载:
libexosip2-5.2.1
2.编译安装osip2
libosip2-5.2.1/INSTALL
文件中编译说明:
Here is a list of options you can give to the 'configure' command line:
configure --disable-mt ==> disable any thread support,
flags: "-DOSIP_MONOTHREAD"
configure --disable-debug ==> disable debug.
configure --disable-trace ==> disable the trace in the logfile.
flags: "-UENABLE_TRACE"
configure --prefix=/your/local ==> install in '$prefix' (default is /usr/local)
当 configure
没有配置--disable-mt
或 -DOSIP_MONOTHREAD
时,报错如下图:
2.1解决报错
解决报错:需要依赖pthreads-win32
首先修改libosip2-5.2.1include/osip2/internal.h
,在126行#ifndef OSIP_MONOTHREAD
下面插入一行如下:
#define HAVE_PTHREAD_WIN32 1 // 依赖 pthreads-win32
继续修改libosip2-5.2.1include/osip2/osip_condv.h
,在58行对struct timespec
添加宏判断(为了解决exosip2编译报错),如下:
#if !defined(HAVE_SYS_TYPES_H) //添加 防止在编译exosip2是类型重定义
/**
* timespec structure
* @struct timespec
*/
struct timespec {
long tv_sec;
long tv_nsec;
};
#endif //添加 防止在编译exosip2是类型重定义
2.2编译
脚本如下:
#!/bin/bash
CUR_DIR=$(pwd)
BUILD_DIR=${CUR_DIR}/build_mingwX64
INSTALL_DIR=${CUR_DIR}/build_mingwX64/libosip
PTHREAD_W32_INCLUDE_DIR=/d/cppwork/devEnv/pthreads-w32-2-9-1-release/Pre-built.2/include
PTHREAD_W32_LIB_DIR=/d/cppwork/devEnv/pthreads-w32-2-9-1-release/Pre-built.2/lib/x64
if [ ! -d ${BUILD_DIR} ]; then
mkdir ${BUILD_DIR}
fi
cd ${BUILD_DIR}
../configure --prefix=${INSTALL_DIR}
LDFLAGS="-L${PTHREAD_W32_LIB_DIR}"
CPPFLAGS="-I${PTHREAD_W32_INCLUDE_DIR}"
LIBS="-lpthreadGC2"
&& make && make install
3.编译安装exosip2
3.1编译报错
见 2.1解决报错
3.2编译
脚本如下:
#!/bin/bash
CUR_DIR=$(pwd)
BUILD_DIR=${CUR_DIR}/build_mingwX64
INSTALL_DIR=${CUR_DIR}/build_mingwX64/libexosip
PTHREAD_W32_INCLUDE_DIR=/d/cppwork/devEnv/pthreads-w32-2-9-1-release/Pre-built.2/include
PTHREAD_W32_LIB_DIR=/d/cppwork/devEnv/pthreads-w32-2-9-1-release/Pre-built.2/lib/x64
OSIP_INCLUDE_DIR=/d/cppwork/devEnv/libosip2-5.2.1/build_mingwX64/libosip/include
OSIP_LIB_DIR=/d/cppwork/devEnv/libosip2-5.2.1/build_mingwX64/libosip/lib
OPENSSL_INCLUDE_DIR=/d/cppwork/devEnv/openssl1.0.0d_ming64_gcc8.1.0/mingw64_build/include
OPENSSL_LIB_DIR=/d/cppwork/devEnv/openssl1.0.0d_ming64_gcc8.1.0/mingw64_build/lib
if [ ! -d ${BUILD_DIR} ]; then
mkdir ${BUILD_DIR}
fi
cd ${BUILD_DIR}
../configure --prefix=${INSTALL_DIR}
LDFLAGS="-L${OSIP_LIB_DIR} -L${PTHREAD_W32_LIB_DIR} -L${OPENSSL_LIB_DIR}"
CPPFLAGS="-I${OSIP_INCLUDE_DIR} -I${PTHREAD_W32_INCLUDE_DIR} -I${OPENSSL_INCLUDE_DIR}"
LIBS="-losipparser2 -lpthreadGC2 -lssl -lcrypto -lCrypt32"
&& make && make install
最后
以上就是拉长小熊猫为你收集整理的GB28181协议——SIP开发环境搭建的全部内容,希望文章能够帮你解决GB28181协议——SIP开发环境搭建所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复