Android FFmpeg : Undefined references to atof, log2 & log2f

Issue

I am trying to link to FFmpeg built for android using android-ndk-r15c. I built this by downloading FFmpeg source that is latest ffmpeg-3.3.4.

Following are my linker list:

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

I get the following errors complaining

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'

Following are my FFmpeg related includes:

#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"

}

Following is my buildscript to cross-compile FFmpeg for android:

#!/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 \
    --archarm \
    --cpucortex-a8 \
    --target-oslinux \
    --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
}

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

build_ffmpeg_android

Question:
Which library am I missing to link to ?

Solution

I ran into this issue building ffmpeg-2.8.15 with x264 using ndk-r10e with platform android-15. I updated the code to use android-21 and it compiled the code without any issues. Our min sdk version is 21.

Answered By – Ray Hunter

Leave a Comment