1. 下载源码
https://files.freeswitch.org/freeswitch-releases/freeswitch-1.10.7.-release.tar.gz
2. 编写交叉编译脚本build.sh
#!/bin/bash
export ROOTDIR=$(cd `dirname $0`; pwd)
export INSTALL_PREFIX=/data/freeswitch2
export EXTERNAL_PREFIX=/data/ext-freeswitch2
export TCHAIN_PREFIX=/opt/aarch64/aarch64-buildroot-linux-gnu/sysroot
export TCHAIN=${TCHAIN_PREFIX}/../../bin/aarch64-linux
export CC="${TCHAIN}-gcc"
export CXX="${TCHAIN}-g++"
export AR=${TCHAIN}-ar
export LD=${TCHAIN}-ld
export CFLAGS=" \
-O2 -g \
-DGRANDSTREAM_NETWORKS \
-DHAVE_NETINET_IN_H \
-DSWITCH_DEBUG_RWLOCKS \
-Wno-error \
-Wno-pedantic \
-Wno-unused-value \
-Wno-error=pedantic \
-Wno-error=attributes \
-Wno-error=unused-value \
-Wno-error=sequence-point \
-Wno-error=unused-variable \
-Wno-error=unused-but-set-variable \
-Wno-error=declaration-after-statement \
-DHAVE_PTHREAD_MUTEX_RECURSIVE \
-I${TCHAIN_PREFIX}/usr/include \
-I${TCHAIN_PREFIX}/usr/include/uuid \
-I${TCHAIN_PREFIX}/../../include \
-I${TCHAIN_PREFIX}/usr/include/glib-2.0/glib \
-I${TCHAIN_PREFIX}/usr/lib/glib-2.0/include \
-I${EXTERNAL_PREFIX}/include \
-I${INSTALL_PREFIX}/include \
-I${INSTALL_PREFIX}/include \
-I${INSTALL_PREFIX}/include/sofia-sip-1.13"
export CXXFLAGS="${CFLAGS}"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS=" \
-L${TCHAIN_PREFIX}/usr/lib \
-L${TCHAIN_PREFIX}/usr/lib64 \
-L${EXTERNAL_PREFIX}/lib \
-L${INSTALL_PREFIX}/lib \
-Wl,-rpath=${INSTALL_PREFIX}/lib \
-Wl,-rpath-link=${INSTALL_PREFIX}/lib \
-Wl,-rpath-link=${TCHAIN_PREFIX}/usr/lib \
-Wl,-rpath-link=${TCHAIN_PREFIX}/usr/lib64 \
-Wl,-rpath-link=${EXTERNAL_PREFIX}/lib"
export PKG_CONFIG_PATH="${INSTALL_PREFIX}/lib/pkgconfig:${TCHAIN_PREFIX}/usr/lib/pkgconfig:${TCHAIN_PREFIX}/usr/lib64/pkgconfig:${EXTERNAL_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
export FONTCONFIG_CFLAGS=" \
-I${TCHAIN_PREFIX}/usr/include \
-I${TCHAIN_PREFIX}/../../include \
-I${TCHAIN_PREFIX}/usr/include/uuid \
-I${EXTERNAL_PREFIX}/include"
export FONTCONFIG_LIBS=" \
-L${TCHAIN_PREFIX}/usr/lib \
-L${TCHAIN_PREFIX}/usr/lib64 \
-L${EXTERNAL_PREFIX}/lib"
./rebootstrap.sh
./configure \
--prefix=${INSTALL_PREFIX} \
--build=aarch64-linux-gnu \
--host=aarch64-linux \
--target=aarch64-linux-gnu \
--with-openssl=${INSTALL_PREFIX} \
--without-png \
--disable-srtp \
--disable-libvpx \
--without-freetype \
ac_cv_file__dev_ptmx=yes \
ac_cv_file__dev_urandom=yes \
ac_cv_func_setpgrp_void=yes \
ac_cv_file__dev_zero=yes \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
ac_cv_tcp_nodelay_inherited=yes \
enable_core_odbc_support=no \
ac_cv_func_pthread_rwlock_init=yes //解决apr库中读写锁操作检查失败,导致移植成功后不能处理呼叫问题
3. 编译错误
3.1. apr报错(1)
checking 3rd argument to the gethostbyname_r routines... char
checking if TCP_NODELAY setting is inherited from listening sockets... (cached) yes
checking if O_NONBLOCK setting is inherited from listening sockets... yes
checking whether TCP_NODELAY and TCP_CORK can both be enabled... configure: error: in `/root/project/voip/freeswitch-1.10.7/libs/apr':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
configure: error: ./configure.gnu failed for libs/apr
3.2. apr报错(2)
network_io/unix/sockets.c: In function ‘apr_socket_accept’:
network_io/unix/sockets.c:234:30: error: #if with no expression
#if APR_TCP_NODELAY_INHERITED
^
/root/project/voip/freeswitch-1.10.7/libs/apr/build/apr_rules.mk:201: recipe for target 'network_io/unix/sockets.lo' failed
3.3.?apr-util报错
checking for libpq-fe.h... no
checking for dbd/apr_dbd_mysql.c... configure: error: cannot check for file existence when cross compiling
configure: error: ./configure.gnu failed for libs/apr-util
3.4.?switch_core_media.c报错
src/switch_core_media.c: In function ‘switch_core_media_add_crypto’:
src/switch_core_media.c:1396:2: error: unknown type name ‘bool’
bool multiple_keys = false;
^~~~
src/switch_core_media.c:1396:23: error: ‘false’ undeclared (first use in this function)
bool multiple_keys = false;
^~~~~
src/switch_core_media.c:1396:23: note: each undeclared identifier is reported only once for each function it appears in
src/switch_core_media.c:1490:20: error: ‘true’ undeclared (first use in this function)
multiple_keys = true;
- 添加#include <stdbool.h>头文件即可
3.5.?src/switch_rtp.c报错
make all-recursive
make[1]: Entering directory '/Asterisk/project/voip/freeswitch-1.10.7'
CC src/libfreeswitch_la-switch_core_media.lo
CC src/libfreeswitch_la-switch_rtp.lo
In file included from /root/project/voip/freeswitch-1.10.7/libs/srtp/crypto/include/datatypes.h:49:0,
from /root/project/voip/freeswitch-1.10.7/libs/srtp/crypto/include/rdbx.h:50,
from /root/project/voip/freeswitch-1.10.7/libs/srtp/include/srtp_priv.h:52,
from src/switch_rtp.c:49:
/root/project/voip/freeswitch-1.10.7/libs/srtp/crypto/include/integers.h:100:16: error: conflicting types for ‘uint64_t’
typedef double uint64_t;
^~~~~~~~
In file included from /opt/rk3328/rk64bit/aarch64-buildroot-linux-gnu/sysroot/usr/include/stdint.h:37:0,
from /opt/rk3328/rk64bit/lib/gcc/aarch64-buildroot-linux-gnu/6.4.0/include/stdint.h:9,
from /opt/rk3328/rk64bit/aarch64-buildroot-linux-gnu/sysroot/usr/include/inttypes.h:27,
from ./src/include/switch_platform.h:122,
from ./src/include/switch.h:112,
from src/switch_rtp.c:34:
/opt/rk3328/rk64bit/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/stdint-uintn.h:27:20: note: previous declaration of ‘uint64_t’ was here
typedef __uint64_t uint64_t;
^~~~~~~~
In file included from /opt/aarch64/aarch64-buildroot-linux-gnu/sysroot/usr/include/arpa/inet.h:22:0,
from ./src/include/switch_platform.h:124,
from ./src/include/switch.h:112,
from src/switch_rtp.c:34:
src/switch_rtp.c: In function ‘rtcp_generate_sender_info’:
src/switch_rtp.c:1857:62: error: invalid operands to binary << (have ‘double’ and ‘int’)
sr->ntp_lsw = htonl((u_long)(ntp_usec*(double)(((uint64_t)1)<<32)*1.0e-6)); /* convert microseconds to fraction of 32bits and store result in "least significatn word" */
~~~~~~~~~~~~~^
Makefile:2412: recipe for target 'src/libfreeswitch_la-switch_rtp.lo' failed
make[1]: *** [src/libfreeswitch_la-switch_rtp.lo] Error 1
make[1]: Leaving directory '/Asterisk/project/voip/freeswitch-1.10.7'
- 将libs/srtp/crypto/include/integers.h中typedef double uint64_t;修改为:typedef unsigned long uint64_t;
3.6. 修改modules.conf,注释如下内容
#applications/mod_enum
#applications/mod_signalwire
#codecs/mod_h26x
#codecs/mod_opus
#endpoints/mod_verto
#languages/mod_lua
|