【问题标题】:Android FFmpeg : Undefined references to atof, log2 & log2fAndroid FFmpeg:未定义对 atof、log2 和 log2f 的引用
【发布时间】:2017-10-09 14:13:18
【问题描述】:

我正在尝试使用 android-ndk-r15c 链接到为 android 构建的 FFmpeg。我通过下载最新的 ffmpeg-3.3.4FFmpeg source 来构建它。

以下是我的链接器列表:

-lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice -lpostproc

我收到以下错误抱怨

libavformat/hls.c:783: error: undefined reference to 'atof'
libavcodec/ffv1enc.c:146: error: undefined reference to 'log2'
libavcodec/imc.c:428: error: undefined reference to 'log2f'

以下是我的 FFmpeg 相关包括:

#include <stdint.h>
#include <cstdlib>

#define __STDC_CONSTANT_MACROS

extern "C" {

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/mathematics.h"
#include "libavcodec/version.h"
#include "libavutil/rational.h"
#include "libavutil/avstring.h"
#include "libswscale/swscale.h"

}

以下是我的 buildscript 为 android 交叉编译 FFmpeg:

#!/bin/bash

cd ffmpeg-3.3.4

NDK=/path/to/ndk/android-ndk-r15c
SYSROOT=$NDK/platforms/android-21/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64
AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
CPREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-ar
CC=$TOOLCHAIN/bin/arm-linux-androideabi-gcc
CXX=$TOOLCHAIN/bin/arm-linux-androideabi-g++
LD=$TOOLCHAIN/bin/arm-linux-androideabi-ld
RANLIB=$TOOLCHAIN/bin/arm-linux-androideabi-ranlib
STRIP=$TOOLCHAIN/bin/arm-linux-androideabi-strip

function build_ffmpeg_android {

./configure \
    --prefix=$PREFIX \
    --disable-stripping \
    --arch=arm \
    --cpu=cortex-a8 \
    --target-os=linux \
    --enable-cross-compile \
    --enable-debug \
    --enable-pic \
    --disable-programs \
    --enable-static \
    --disable-shared \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --disable-doc \
    --enable-postproc \
    --enable-swscale \
    --enable-avfilter \
    --enable-avresample \
    --disable-opencl \
    --disable-securetransport \
    --sysroot=$SYSROOT \
    --enable-videotoolbox \
    --enable-avresample \
    --disable-symver \
    #--enable-gpl \
    #--enable-libx264
    $ADDITIONAL_CONFIGURE_FLAG
    make clean
    make -j9
    make install
}

CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"

build_ffmpeg_android

问题:
我想链接到哪个库?

【问题讨论】:

  • 标准 C++ 数学函数位于需要链接的单独库中,称为(简单明了)m。所以添加-lm 链接。
  • 只需添加-lm?似乎还不够。我需要任何其他图书馆吗?我正在使用 C++14
  • 尝试添加--extra-ldflags=-L$SYSROOT/usr/lib/。并检查实际的链接命令是什么样的。它应该从 platforms/android-21/arch-arm/usr/libs 中获取系统库。
  • @AlexCohn 选择 platforms/android-21 下面的任何内容都有效。您可以请发布对此主题的答案以正确关闭此问题。谢谢你的建议。针对 15c 和 android-26 的最新 ndk 构建 FFmpeg 是一个非常糟糕的主意
  • exact buildscriptandroid-21 下运行,使用 ndk r10e 工作。是的。脚本没有变化

标签: android c++ ffmpeg android-ndk atof


【解决方案1】:

我在使用ndk-r10e 和平台android-15 构建ffmpeg-2.8.15x264 时遇到了这个问题。我更新了代码以使用android-21,它编译代码没有任何问题。我们的最小 sdk 版本是21

【讨论】:

    【解决方案2】:

    您还可以选择从 FFMPEG 配置文件中删除这些数学函数并重新构建。您解析的 lib-*.so 文件将不再调用这些符号。

    【讨论】:

      猜你喜欢
      • 2013-04-07
      • 2014-07-26
      • 1970-01-01
      • 2014-08-20
      • 2016-03-08
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多