简体   繁体   中英

Build FFMPEG under Cygwin in Windows OS for Android

For the past couple days, I have been trying hard to build FFMPEG for a Android project on Windows Operating System using android-ndk-14d using Cygwin . I have followed many tutorials out there, and I ahve encountered so many errors while building FFMPEG using build_android.sh.

Here are the steps that I have taken so far.

I downloaded Cygwin and configured all the dependencies that I need for building FFMPEG.

I opened ffmpeg-3.3.1/configure file with a text editor, and changed to the following lines.

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

my build_android.sh is as below

#!/bin/bash
NDK=C:/~/ndk-bundle
SYSROOT=$NDK/platforms/android-21/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi-\
    --target-os=android \
    --arch=arm \
    --cpu=armv7-a \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"
build_one

I ran these commands

dos2unix build_android.sh 
chmod +x build_android.sh
./build_android.sh

and,,,currently getting this error

c:/users/sonic/appdata/local/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/p rebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-an droideabi/bin/ld.exe: error: libavutil/libavutil.so:1:1: syntax error, unexpected '!', exp ecting $end

c:/users/sonic/appdata/local/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/p rebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-an droideabi/bin/ld.exe: error: libavutil/libavutil.so: not an object or archive collect2.exe: error: ld returned 1 exit status make: *** [library.mak:94: libswscale/libswscale-4.so] Error 1 LD

libswscale/libswscale-4.so c:/users/sonic/appdata/local/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/p rebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-an droideabi/bin/ld.exe: error: libavutil/libavutil.so:1:1: syntax error, unexpected '!', exp ecting $end

c:/users/sonic/appdata/local/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/p rebuilt/windows-x86_64/bin/../lib/gcc/arm-linux->androideabi/4.9.x/../../../../arm-linux-an droideabi/bin/ld.exe: error: libavutil/libavutil.so: not an object or archive collect2.exe: error: ld returned 1 exit status make: *** [library.mak:94: libswscale/libswscale-4.so] Error 1

How to compile ffmpeg-2.5.3 on windows with android-ndk-r10d

From the comments that were commented on the above link, it seems like it is easier to build FFMPEG in Linux/Unix OS. My first can be a dumb question. But If there is anyone who can guide me through this, i will be really appreciated it.

If I build FFMPEG on Linux for Android, could I possibly copy or move those resulted output (The arm/lib folder contains the shared libraries, while arm/include folder contains the header files for libavcodec, libavformat, libavfilter, libavutil, libswscale etc.) to Windows OS and utilize them for my Android project?

Since my company only provides Windows OS for a project, I have to utilize them on Windows OS.

Thank you for your time, and if there is any feedback that you can provide it will definitely be helpful.

For the reference, here is my config.log

END c:/ffmpegtmp/ffconf.qoBF6X98.c C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc --sysroot=C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/platforms/android-9/arch-arm/

-isysroot C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/platforms/android-9/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -Os -fpic -marm -march=armv7-a -std=c11 -fomit-frame-pointer -fPIC -marm -pthread -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -c -oc:/ffmpegtmp/ffconf.8joa74tC.o

c:/ffmpegtmp/ffconf.qoBF6X98.c check_cflags -fdiagnostics-color=auto test_cflags -fdiagnostics-color=auto check_cc -fdiagnostics-color=auto BEGIN c:/ffmpegtmp/ffconf.qoBF6X98.c 1 int x; END c:/ffmpegtmp/ffconf.qoBF6X98.c C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc --sysroot=C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/platforms/android-9/arch-arm/

-isysroot C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/platforms/android-9/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -Os -fpic -marm -march=armv7-a -std=c11 -fomit-frame-pointer -fPIC -marm -pthread -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -c -oc:/ffmpegtmp/ffconf.8joa74tC.oc:/ffmpegtmp/ffconf.qoBF6X98.c test_cflags -Wmaybe-uninitialized check_cc -Wmaybe-uninitialized BEGIN

c:/ffmpegtmp/ffconf.qoBF6X98.c 1 int x; END c:/ffmpegtmp/ffconf.qoBF6X98.c C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc --sysroot=C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/platforms/android-9/arch-arm/

-isysroot C:/Users/sonic/AppData/Local/Android/sdk/ndk-bundle/platforms/android-9/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -Os -fpic -marm -march=armv7-a -std=c11 -fomit-frame-pointer -fPIC -marm -pthread -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wmaybe-uninitialized -c -oc:/ffmpegtmp/ffconf.8joa74tC.oc:/ffmpegtmp/ffconf.qoBF6X98.c

If you use the same compiler version with the same ABI (application binary interface) then it should be no problem. I have done so with RISC-V libraries before and I imagine it's no different with ARM.

In fact that's exactly what you're doing on Windows with the Android NDK, compiling ARM binaries to run on Linux! Whether you crosscompile FFMPEG on Windows or Linux you still end up with the same binaries that are able to run on the same Android system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM