交叉编译APR&APR-Util

本文介绍了如何在Windows10环境下,通过WSL和Ubuntu18,为嵌入式主板上的Freeswitch进行arm-linux-gnueabihf的交叉编译,包括下载交叉编译链、配置APR和APR-Util的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景

        由于需要在嵌入式主板运行freeswitch, 故需将其交叉编译运行在arm平台上。在网上找了一通均无实现方式。只好先学习一下autoconf, automake和libtool,然后拿apr练一下如何交叉编译。此文参考了apche2移植到Arm开发板的过程。我的主机是WIN10,安装了wsl和ubuntu18。另外使用windows商店安装的terminal工具,非常方便在windows中开发linux系统。

准备工作

  1. 下载交叉编译链
    1. 我使用的是arm-linux-gnueabihf,具体下载请网上查询
    2. 先更新一下安装源,避免下载更新失败,请查看:更新国内下载源
    3. 使用如下命令安装:
    4. sudo apt-get install gcc-arm-linux-gnueabihf

      如上安装完后,将会自动 配置好路径,此时可以通过如下命令验证是否有效:

    5. arm-linux-gnueabihf-gcc -v
      Using built-in specs.
      COLLECT_GCC=arm-linux-gnueabihf-gcc
      COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/7/lto-wrapper
      Target: arm-linux-gnueabihf
      Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include
      Thread model: posix
      gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)

  2. freeswitch1.8.x下载地址下载APR和APR-Util
    1. 我使用freeswitch源代码包中的apr版本,下载地址:freeswitch1.8下载地址

编译APR

        首先在apr源代码根目录下创建arm-linux.cache文件,内容如下:

ac_cv_file__dev_zero=yes 
ac_cv_func_setpgrp_void=yes 
apr_cv_tcp_nodelay_with_cork=yes 
#下面根据具体系统环境添加
apr_cv_process_shared_works=yes
apr_cv_mutex_robust_shared=yes

        其次修改configure.ac文件:(主要增加av_cv_sizeof_long_long判断,否则make会报错)

if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
    ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
    ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long_long"; then
    ssize_t_fmt='#define APR_SSIZE_T_FMT "lld"'
else
    ssize_t_fmt='#error Can not determine the proper size for ssize_t'
fi

if test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
    size_t_fmt='#define APR_SIZE_T_FMT "d"'
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
    size_t_fmt='#define APR_SIZE_T_FMT "ld"'
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long_long"; then
    size_t_fmt='#define APR_SIZE_T_FMT "lld"'
else
    size_t_fmt='#define APR_SIZE_T_FMT "zu"'
fi

        修改完后执行如下命令更新configure脚本

autoconf

交叉编译的命令如下:

./configure --prefix=/usr/local/apr --host=arm-linux-gnueabihf --cache=arm-linux.cache

编译安装:

make
make install

编译APR-Util

        由于源文件默认不带dbd/apr-mysql.c文件(如果要下载请参考INSTALL.MYSQL文件),故需要修改configure.ac文件:(注释掉MYSQL的检查)

APU_CHECK_DBD
dnl APU_CHECK_DBD_MYSQL
APU_CHECK_DBD_SQLITE3
APU_CHECK_DBD_SQLITE2

        然后运行如下命令:

autoconf
./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr --host=arm-linux-gnueabihf
make && make install

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值