使用Android工具链与autoconf交叉编译
问题描述:
目标使用NDK工具链为Android编译思科libsrtp并使用libsrtp.a静态链接到我自己的库。使用Android工具链与autoconf交叉编译
设置:我使用以下文件
<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
这编译对我来说。收益率 -
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如何获得这些?
我以前使用类似的东西建立了相同的库,我知道它构建。我不知道错误可能是什么。
答
我通常会在21之后的任何平台上使用libc获得这个未定义的引用,因此我通常会将-D__ANDROID_API __ = 21添加到CFLAGS中,并最终修复它。我相信这个问题来自于更新的ndk版本中的新统一头文件。
它的工作!我没有添加这个标志,但我更改了Application.mk中的Android NDK版本,并开始编译。 :)。 – Pranay