使用 cygwin 在 Windows 上编译 ffmpeg 时出现问题

2024-02-13

最近在Windows上编译ffmpeg遇到了很多麻烦。我目前正在使用 cgywin 终端来运行代码。我尝试过遵循网络上许多最流行的教程,但我似乎无法让它发挥作用。我目前正在使用本教程作为指南http://www.roman10.net/how-to-build-ffmpeg-for-android/ http://www.roman10.net/how-to-build-ffmpeg-for-android/

我在哪里:

我创建了一个 bash 脚本

#!/bin/bash

NDK=C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64
function build_one
{
./configure --target-os=linux \
    --prefix=$PREFIX \
    --enable-cross-compile \
    --extra-libs="-lgcc" \
    --arch=arm \
    --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
    --sysroot=$PLATFORM \
    --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
    --disable-shared \
    --enable-static \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
    --disable-everything \
    --enable-demuxer=mov \
    --enable-demuxer=h264 \
    --disable-ffplay \
    --enable-protocol=file \
    --enable-avformat \
    --enable-avcodec \
    --enable-decoder=rawvideo \
    --enable-decoder=mjpeg \
    --enable-decoder=h263 \
    --enable-decoder=mpeg4 \
    --enable-decoder=h264 \
    --enable-parser=h264 \
    --disable-network \
    --enable-zlib \
    --disable-avfilter \
    --disable-avdevice \
    $ADDITIONAL_CONFIGURE_FLAG

make clean
make  -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}

#arm v6
#CPU=armv6
#OPTIMIZE_CFLAGS="-marm -march=$CPU"
#PREFIX=./android/$CPU 
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one

#arm v7vfp
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
#PREFIX=./android/$CPU-vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

#arm v7n
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
#PREFIX=./android/$CPU 
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon
#build_one

#arm v6+vfp
#CPU=armv6
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
#PREFIX=./android/${CPU}_vfp 
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

然后我按照这篇文章的步骤 4-6 进行操作有人觉得这有用吗? - 使用 Cywin 和 NDK r5 在 Windows 上编译 FFMPEG https://stackoverflow.com/questions/10665039/does-anyone-find-this-useful-compiling-ffmpeg-on-windows-with-cywin-and-ndk-r其中包括

4 - Open the file 'configure' in the root of the FFMPEG directory in a text editor.

5 - Comment out lines 2073, 2074 and 2075.

6 - Below 2075, add the following line:

TMPDIR=c:/cygwin/tmp

当我在 cygwin 中运行脚本时,我得到了这个结果:

    install prefix            ./android/armv7-a
source path               .
C compiler                C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc
ARCH                      arm (armv7-a)
big-endian                no
runtime cpu detection     yes
ARMv5TE enabled           yes
ARMv6 enabled             yes
ARMv6T2 enabled           yes
VFP enabled               yes
NEON enabled              yes
THUMB enabled             no
debug symbols             yes
strip symbols             yes
optimize for size         no
optimizations             yes
static                    yes
shared                    no
postprocessing support    no
new filter support        no
network support           no
threading support         pthreads
safe bitstream reader     yes
SDL support               no
opencl enabled            no
texi2html enabled         no
perl enabled              no
pod2man enabled           no
makeinfo enabled          no

External libraries:
zlib

Enabled decoders:
h263                    mjpeg                   rawvideo
h264                    mpeg4

Enabled encoders:

Enabled hwaccels:

Enabled parsers:
h263                    h264                    mpeg4video

Enabled demuxers:
h264                    mov

Enabled muxers:

Enabled protocols:
file

Enabled filters:

Enabled bsfs:

Enabled indevs:

Enabled outdevs:

License: LGPL version 2.1 or later
Creating config.mak, config.h, and doc/config.texi...
libavutil/avconfig.h is unchanged

WARNING: C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.
library.mak:105: *** missing separator.  Stop.
library.mak:105: *** missing separator.  Stop.
C:\Users\jrblain\Development\adt-bundle-windows-x86_64-20130514\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: ,noexecstack: unknown -z option
C:\Users\jrblain\Development\adt-bundle-windows-x86_64-20130514\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: use the --help option for usage information

运行此脚本后,我会在 ffmpeg 文件夹中获得一些新文件。它们是 .config、config(header)、config.mak 、config.fate。 android 文件夹从未像预期的那样创建。我也不确定 library.mak 错误是从哪里来的,因为它是随 ffmpeg 下载一起提供的。

我不确定我在这一切中哪里出了问题。我觉得我使用 Windows 的事实将使这个构建过程有所不同。


第一个错误显示“警告:C:/.../arm-linux-androideabi-pkg-config 未找到,库检测可能会失败。”所以我建议修复路径。

“C:/”不是 POSIX 路径。 Cygwin 程序能够翻译它(带有警告)。

cd 'c:' # works. cd is a built-in command
ls 'c:' # doesn't work
ls 'c:/' # works (edited)

有关 Cygwin 如何映射的文档POSIX 和 Win32 样式路径 http://cygwin.com/cygwin-ug-net/using.html#using-pathnames.

根据我的经验,当您混合斜杠和反斜杠或从 Cygwin 调用 Windows 本机命令时,您会遇到问题。Example https://cygwin.com/cygwin-ug-net/using-effectively.html:

javac -cp "$(cygpath -pw "$CLASSPATH")" hello.java

在我看来,您应该硬编码 POSIX 路径,或使用以下命令:

cygpath -u 'c:' # the relevant command provided by Cygwin
(cd 'c:' && pwd) # a tip, useful if you want a portable syntax

但也许我完全错了。我想你已经检查过路径

ls 'C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-pkg-config'

我想你已经检查了 mk 文件的第 105 行(制表和 linux换行).

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 cygwin 在 Windows 上编译 ffmpeg 时出现问题 的相关文章

随机推荐