[FFmpeg-devel] build for Android on WIndows

Alex Cohn alexcohn at netvision.net.il
Tue Jun 24 12:46:22 CEST 2014

When we build ffmpeg for Android in Windows (using cygwin or Mingw
shell), and enable NEON, make for libavcodec fails because the LD and
AR command lines become too long.

I suggest a simple patch which is not cygwin dependent. I am not sure
if this patch will resolve all problems for everybody.

diff --git a/library.mak b/library.mak
index cd39f11..88ad0a4 100644
--- a/library.mak
+++ b/library.mak
@@ -33,7 +33,8 @@ $(TESTOBJS) $(TESTOBJS:.o=.i): CPPFLAGS += -DTEST

        $(RM) $@
-       $(AR) $(ARFLAGS) $(AR_O) $^
+       $(AR) $(ARFLAGS) $(AR_O) $(wordlist 1,400,$^)
+       $(AR) $(ARFLAGS) $(AR_O) $(wordlist 401,999,$^)
        $(RANLIB) $@

 install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig

-       $$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
+       $(Q)echo >$(SUBDIR)lib$(NAME).list $(wordlist 1,400,$(filter %.o,$$<))
+       $(Q)echo >>$(SUBDIR)lib$(NAME).list $(wordlist 401,999,$(filter %.o,$$<)
+       $$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O)
+       -$(RM) $(SUBDIR)lib$(NAME).list

 ifdef SUBDIR

See http://stackoverflow.com/questions/23683518/how-to-compile-ffmpeg-2-2-2-on-windows-with-cygwin-and-android-ndk-r9c

I propose this patch with a grain of doubt. On one hand, I am not sure
if all supported toolchains handle the LD @response syntax, exactly
the same way as gcc does. On the other hand, I left aside the similar
problem for `make clean`, because I could not verify all scenarios
that can happen with `make clean`. Also, using $(wordlist) is an ugly
hack, but unfortunately `make.exe` v.3.81 that ships with Android NDK
r9d still does not support $(file) function.

Alex Cohn

More information about the ffmpeg-devel mailing list