代码之家  ›  专栏  ›  技术社区  ›  Pranay

使用Android工具链与autoconf交叉编译

  •  1
  • Pranay  · 技术社区  · 7 年前

    客观的 交叉编译Cisco libsrtp

    安装程序 :我使用以下文件

    <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时。作为一个预构建的静态库,我遇到以下错误:

    ./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是如何获得这些的呢?

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

    1 回复  |  直到 7 年前
        1
  •  1
  •   Surge1223    7 年前

    我通常在21岁之后的任何平台上都会得到libc的这个未定义引用,所以我通常会将-D\u ANDROID\u API\u=21添加到CFLAGS中,最后它会修复它。我相信这个问题来自新ndk版本中的新统一头。