在過去的幾天裏,我一直在努力以爲基礎,在Windows操作系統上使用android-ndk-14d使用Cygwin構建FFMPEG。 我遵循了很多教程,並且在使用build_android.sh構建FFMPEG時遇到了很多錯誤。在Windows操作系統下爲Cygwin構建FFMPEG
以下是我到目前爲止所採取的步驟。
我下載了Cygwin並配置了構建FFMPEG所需的所有依賴關係。
我用文本編輯器打開了ffmpeg-3.3.1/configure文件,並更改爲以下幾行。
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'
我build_android.sh是如下
#!/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
我跑這些命令
dos2unix build_android.sh
chmod +x build_android.sh
./build_android.sh
和,,,目前收到此錯誤
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
從上面鏈接評論的評論看來,它似乎是在Linux/Unix操作系統中更容易構建FFMPEG的 。我的第一個可能是一個愚蠢的問題。但是如果有人能夠指導我完成這個任務,我會非常感激。
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?
由於我公司只提供Windows操作系統的一個項目,我必須利用他們在Windows操作系統。
謝謝你的時間,如果有任何反饋,你可以提供它肯定會有所幫助。
對於參考,這是我的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 -o c:/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 -o c:/ffmpegtmp/ffconf.8joa74tC.o c:/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 -o c:/ffmpegtmp/ffconf.8joa74tC.o c:/ffmpegtmp/ffconf.qoBF6X98.c
對於那些正在努力在Windows上使用Cygwin構建FFMPEG的人,像我自己花了幾天的時間去挖掘構建方法,請查看此鏈接[https://medium.com/@ilja.kosynkin/building -ffmpeg換Android的607222677a9e。它真的幫了我很多。它可以讓你掌握構建Android的FFMPEG的整個概念。 –