[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

 $(SUBDIR)$(LIBNAME): $(OBJS)
        $(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
@@ -53,7 +54,10 @@ $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)

 $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver
        $(SLIB_CREATE_DEF_CMD)
-       $$(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)
@$(SUBDIR)lib$(NAME).list $(FFEXTRALIBS)
+       -$(RM) $(SUBDIR)lib$(NAME).list
        $(SLIB_EXTRA_CMD)

 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.

BR,
Alex Cohn


More information about the ffmpeg-devel mailing list