Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#2890 closed defect (invalid)

Compile ffmpeg for Android on OSX failes (ld)

Reported by: fscz Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
during compilation of libavutil

following error shows up:

LD libavutil/libavutil.52.dylib
/Users/fschuetz/tmp/ffmpeg/build/toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: -single_module: unknown option
/Users/fschuetz/tmp/ffmpeg/build/toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
make: * [libavutil/libavutil.52.dylib] Error 1

How to reproduce:
checkout https://github.com/FFmpeg/FFmpeg

build, using ndk9:


#!/bin/bash

##CONFIGURATION ###################################################

NDK=/opt/android-ndk-r9
TARGET_OS=darwin
BUILD=$(pwd)/build/dest
TOOLCHAIN=$(pwd)/build/toolchain
SYSROOT=$TOOLCHAIN/sysroot

FFMPEG_FLAGS="--prefix=${BUILD} \

--target-os=${TARGET_OS} \
--arch=arm \
--enable-thumb \
--enable-cross-compile \
--cross-prefix=arm-linux-androideabi- \
--disable-programs \
--disable-everything \
--disable-asm \
--disable-symver \
--disable-doc \
--disable-devices \
--disable-bsfs \
--disable-network \
--enable-avdevice \
--enable-avcodec \
--enable-avutil \
--enable-swresample \
--enable-swscale \
--enable-debug \
--disable-postproc \
--disable-avfilter \
--enable-gpl \
--enable-version3 \
--enable-shared \

--enable-static \
--enable-rdft \
--enable-ffmpeg \
--enable-protocol=file
--enable-parser=aac \
--enable-parser=ac3 \
--enable-parser=mpegaudio \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=ape \
--enable-demuxer=asf \
--enable-demuxer=flac \
--enable-demuxer=matroska_audio \
--enable-demuxer=mp3 \
--enable-demuxer=mpc \
--enable-demuxer=mov \
--enable-demuxer=mpc8 \
--enable-demuxer=ogg \
--enable-demuxer=tta \
--enable-demuxer=wav \
--enable-demuxer=wv \
--enable-decoder=aac \
--enable-decoder=ac3 \
--enable-decoder=alac \
--enable-decoder=ape \
--enable-decoder=flac \
--enable-decoder=mp1 \
--enable-decoder=mp2 \
--enable-decoder=mp3 \
--enable-decoder=mpc7 \
--enable-decoder=mpc8 \
--enable-decoder=tta \
--enable-decoder=vorbis \
--enable-decoder=wavpack \
--enable-decoder=wmav1 \
--enable-decoder=wmav2 \
--enable-decoder=pcm_alaw \
--enable-decoder=pcm_dvd \
--enable-decoder=pcm_f32be \
--enable-decoder=pcm_f32le \
--enable-decoder=pcm_f64be \
--enable-decoder=pcm_f64le \
--enable-decoder=pcm_s16be \
--enable-decoder=pcm_s16le \
--enable-decoder=pcm_s16le_planar \
--enable-decoder=pcm_s24be \
--enable-decoder=pcm_daud \
--enable-decoder=pcm_s24le \
--enable-decoder=pcm_s32be \
--enable-decoder=pcm_s32le \
--enable-decoder=pcm_s8 \
--enable-decoder=pcm_u16be \
--enable-decoder=pcm_u16le \
--enable-decoder=pcm_u24be \
--enable-decoder=pcm_u24le \
--enable-decoder=rawvideo"

##END ###################################################

$NDK/build/tools/make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.6 --platform=android-14 --system=darwin-x86_64 --install-dir=$TOOLCHAIN

export PATH=$TOOLCHAIN/bin:$PATH
export CC=arm-linux-androideabi-gcc
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar

CFLAGS="-O3 -Wall -mthumb -pipe -fpic -fasm \

-finline-limit=300 -ffast-math \
-fstrict-aliasing -Werror=strict-aliasing \
-fmodulo-sched -fmodulo-sched-allow-regmoves \
-Wno-psabi -Wa,--noexecstack \
-DANDROID -DNDEBUG"

EXTRA_CFLAGS="-march=armv7-a -mthumb -mthumb-interwork -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-quad"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"

./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS"

make clean
make -j
make install


built on osx 10.8

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Change History (6)

comment:1 Changed 3 years ago by fscz

-single_module is added to the linker from the configure script (3496):


SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_W\
ITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'


unfortunately
-install_name
-current_version
-compatibility_version
are also unknown

also problematic is the following line (3499)
---
add_ldflags -Wl,-dynamic,-search_paths_first
---
as search_paths_first throws an error, too

If i remove all those flags and write the following:
---
SHFLAGS='-dynamiclib'
add_ldflags -WL,-dynamic
---

I get the following error:
---
LD libavutil/libavutil.52.dylib
/Users/fschuetz/tmp/ffmpeg/build/toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /Users/fschuetz/tmp/ffmpeg/build/toolchain/bin/../sysroot/usr/lib/crtbegin_dynamic.o: in function _start:crtbrand.c(.text+0x78): error: undefined reference to 'main'
collect2: ld returned 1 exit status
make: * [libavutil/libavutil.52.dylib] Error 1
---

comment:2 Changed 3 years ago by cehoyos

Sorry if I miss something but isn't there a tiny difference between "darwin" (the target_os you set in your script and "Android" (the target_os in the ticket's title)?

Your configure script is unfortunately impossible to parse (apparently even for you), please don't use it, instead start with a minimal configure line, something like ./configure --cross-prefix=arm-linux-androideabi- --target-os=linux --arch=armv7-a and once that works, add your remaining (mostly strange) options that you believe to need.

Last edited 3 years ago by cehoyos (previous) (diff)

comment:3 follow-up: Changed 3 years ago by fscz

Yeah thanks. You got that all figured out. I did not name those options and you obviously have no clue what you are talking about. But if you run across any splendid documentation on all the configure options, let me know.

comment:4 in reply to: ↑ 3 Changed 3 years ago by cehoyos

  • Component changed from build system to undetermined
  • Keywords build ld removed
  • Resolution set to invalid
  • Status changed from new to closed

Replying to fscz:

Yeah thanks. You got that all figured out. I did not name those options

Which options did you not name?

and you obviously have no clue what you are talking about.

That is probably true, however since you obviously need support and don't have a bug to report, please use the ffmpeg-user mailing list.

But if you run across any splendid documentation on all the configure options, let me know.

configure --help works fine here.

comment:5 follow-up: Changed 3 years ago by fscz

You should go to bed. If you're lucky, you're back to normal tomorrow.
If not, I fear the worst.

By the way, I was able to solve this by changing:

--enable-shared \
--enable-static \

to

--enable-static \

from the sparse documentation in the ./configure
scripts it is not really clear, what those options do:

--disable-static do not build static libraries [no]
--enable-shared build shared libraries [no]

comment:6 in reply to: ↑ 5 Changed 3 years ago by cehoyos

Replying to fscz:

You should go to bed. If you're lucky, you're back to normal tomorrow.

You mean tomorrow darwin and Android will be the same?

Note: See TracTickets for help on using tickets.