【问题标题】:Cross Compile with autoconf with Android toolchain使用 Android 工具链使用 autoconf 进行交叉编译
【发布时间】:2017-10-11 02:23:13
【问题描述】:

目标使用 NDK 工具链交叉编译 Cisco libsrtp for Android 并使用 libsrtp.a 静态链接到我自己的库。

设置:我使用以下文件

<setup.sh>
  export CROSS_SYSROOT=/home/psurana/aa/sysroot
  export CROSS_COMPILE=aarch64-linux-android-
  export SYSROOT=/home/psurana/aa/sysroot
  export CC="${CROSS_COMPILE}gcc  --sysroot=${SYSROOT}"
  export CXX="${CROSS_COMPILE}gxx --sysroot=${SYSROOT}" 
  PATH=/home/psurana/aa/bin:$PATH

然后我进行以下配置:

source setup.sh && ./configure --host=aarch64-linux-android --build=`./config.guess` && make -j

这是为我编译的。做一个readelf -h libsrtp.a,产生--

File: libsrtp.a(ut_sim.o)
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           AArch64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          1480 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         10
  Section header string table index: 7

到目前为止一切顺利。

问题

但是,当我将 libsrtp.a 链接为预构建的静态库时,出现以下错误:

./srtp/libsrtp.a(rand_source.o): In function `rand_source_init':

err.c:(.text+0x0): undefined reference to `stdout'
err.c:(.text+0xc): undefined reference to `stdout'

和,

rand_source.c:(.text+0x28): undefined reference to `stderr'
rand_source.c:(.text+0x3c): undefined reference to `stderr'

我的理解是Android的libc中没有stderr,那么libsrtp是怎么得到这些的呢?

我之前使用类似的东西构建了相同的库,我知道它可以构建。我不知道错误可能是什么。

【问题讨论】:

    标签: android android-ndk autotools autoconf


    【解决方案1】:

    我通常在 21 之后的任何平台上使用 libc 获得这个未定义的引用,所以我通常将 -D__ANDROID_API__=21 添加到 CFLAGS 并最终修复它。我相信问题出在较新的 ndk 版本中的新统一标头。

    【讨论】:

    • 成功了!我没有添加这个标志,但是我在 Application.mk 中更改了 Android NDK 版本并开始编译。 :)。
    猜你喜欢
    • 2016-03-16
    • 1970-01-01
    • 2013-02-20
    • 2013-10-21
    • 2019-01-08
    • 1970-01-01
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多