binglingziyu / ffmpeg-android-build

Other
22 stars 17 forks source link

cannot compile on macOS Catalina #2

Closed singlepig closed 4 years ago

singlepig commented 4 years ago

你好,我将你的这个项目clone下来以后,只修改了ndk路径,执行./build_android.sh报错。

/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory

ndk-r20b是官网下的,解压后跟Android sdk放一起了,这个clang文件确实是存在的,ls 看过了。前段时间系统升级到Catalina,不知道是不是跟系统不兼容啊??

config.log里有很多

clang: warning: joined argument expects additional value: '-mcpu=' [-Wunused-command-line-argument]
clang: error: the clang compiler does not support '-march=core2'

这样的报错。完整文件在这里。https://send.firefox.com/download/7442922aa51fa9e3/#tB6x0L4bwHoF47lUwHhauA

求助,不胜感激!

系统macOS 10.15.2 (19C57)

binglingziyu commented 4 years ago

周末我试试,现在用的 Windows。

binglingziyu commented 4 years ago

@singlepig 我试了一遍没有问题。

看你的报错 **/bin/aarch64-linux-android21-clang is unable to create an executable file. C compiler test failed.

你应该是要编译 arm64so

我添加了一个 build_android_64.sh,我试了一遍可以编译出 so,你可以看看。

$ cd Desktop/ffmpeg4.2

# 设置 build_android_64.sh 可执行权限
$ chmod +x build_android_64.sh

# configure 对 FFmpeg 进行配置
$ ./build_android_64.sh

# 编译
$ make -j 8

$ make install
~/Desktop/FFmpeg/ffmpeg-android-build   master ●  cd android/armv8-a/lib

~/Desktop/FFmpeg/ffmpeg-android-build/android/armv8-a/lib   master ●  ll
total 35544
-rwxr-xr-x  1 staff  staff    11M  1 12 22:27 libavcodec.so
-rwxr-xr-x  1 staff  staff    61K  1 12 22:27 libavdevice.so
-rwxr-xr-x  1 staff  staff   2.6M  1 12 22:27 libavfilter.so
-rwxr-xr-x  1 staff  staff   2.3M  1 12 22:27 libavformat.so
-rwxr-xr-x  1 staff  staff   431K  1 12 22:27 libavutil.so
-rwxr-xr-x  1 staff  staff    88K  1 12 22:27 libswresample.so
-rwxr-xr-x  1 staff  staff   477K  1 12 22:27 libswscale.so
drwxr-xr-x  9 staff  staff   288B  1 12 22:27 pkgconfig
singlepig commented 4 years ago

@binglingziyu 非常感谢!顺便问一句,你是用的什么版本的macOS? 我重新pull了,只改了ndk路径,我试了一下,终于,还是失败了,😂

#  (base) singlepig in ~/tmp/ffmpeg-android-build on git:master x  [9:25:52]
$ ./build_android_64.sh
/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory
sed: config.h: No such file or directory

#  (base) singlepig in ~/tmp/ffmpeg-android-build on git:master x  [9:25:58] C:1
$ ll /Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang
-rwxr-xr-x@ 1 singlepig  staff   187B Oct 17 15:46 /Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang

#  (base) singlepig in ~/tmp/ffmpeg-android-build on git:master x  [9:26:05]
$ /Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang
clang: error: no input files

可以看到,这个文件我明明是存在的,但是它就是报错😂。 下面是截取的 ffbuild/config.log的头部和尾部内容

# ./configure --prefix=/Users/singlepig/tmp/ffmpeg-android-build/android/armv8-a --ar=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar --as=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-as --cc=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang --cxx=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang++ --nm=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-nm --ranlib=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ranlib --strip=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-strip --arch=aarch64 --target-os=android --enable-cross-compile --disable-asm --enable-shared --disable-static --disable-ffprobe --disable-ffplay --disable-ffmpeg --disable-debug --disable-symver --disable-stripping --extra-cflags='-Os -fpic -DANDROID -I/Users/singlepig/Library/Android/sdk/android-ndk-r20b/sysroot/usr/include/aarch64-linux-android/' --extra-ldflags='-Wl,-rpath-link=/Users/singlepig/Library/Android/sdk/android-ndk-r20b/platforms/android-21/arch-arm64/usr/lib -L/Users/singlepig/Library/Android/sdk/android-ndk-r20b/platforms/android-21/arch-arm64/usr/lib -nostdlib'
ALL_COMPONENTS='

    aac_adtstoasc_bsf
av1_frame_split_bsf
av1_metadata_bsf
chomp_bsf
dump_extradata_bsf
dca_core_bsf
eac3_core_bsf
extract_extradata_bsf
filter_units_bsf
h264_metadata_bsf
h264_mp4toannexb_bsf

// 省略很多行

zmbv_decoder=yes
zmbv_decoder_deps=zlib
zmbv_encoder=yes
zmbv_encoder_deps=zlib
zmq_filter=yes
zmq_filter_deps=libzmq
zoompan_filter=yes
zoompan_filter_deps=swscale
zscale_filter=yes
zscale_filter_deps='libzimg const_nan'
mktemp -u XXXXXX
QjwyGt
test_ld cc
test_cc
BEGIN /var/folders/c9/6smkj94d0h7_mst6vhtckrb80000gn/T//ffconf.K3vkn0s1/test.c
    1   int main(void){ return 0; }
END /var/folders/c9/6smkj94d0h7_mst6vhtckrb80000gn/T//ffconf.K3vkn0s1/test.c
/Users/singlepig/Library/Android/sdk/android-ndk-r20b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Os -fpic -DANDROID -I/Users/singlepig/Library/Android/sdk/android-ndk-r20b/sysroot/usr/include/aarch64-linux-android/ -c -o /var/folders/c9/6smkj94d0h7_mst6vhtckrb80000gn/T//ffconf.K3vkn0s1/test.o /var/folders/c9/6smkj94d0h7_mst6vhtckrb80000gn/T//ffconf.K3vkn0s1/test.c
clang: error: the clang compiler does not support '-march=core2'
C compiler test failed.

头部的那些路径我都检查过,都存在。尾部的错误,我自己再研究一下。 之前ffmpeg一直无法编译成功,搞了三天了,要爆炸了,到现在也没搞定,实在不行了,后来上周五用docker拉ubuntu容器编,虽然慢了点,但是一把过!😂

singlepig commented 4 years ago

锅找到了!是之前安装conda的时候在zshrc里加了一段官方文档里面写的shell,加了之后,我的shell环境中就多了这么些东西!

CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe
DEBUG_CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra
CXXFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0
DEBUG_CXXFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -Og -g -Wall -Wextra

core2的那个问题就是这么来的。 真是太坑了! 我是看configure文件里面的test_cc()方法,

test_cc(){
    log test_cc "$@"
    cat > $TMPC
    log_file $TMPC
    echo "===="
    echo $cc
    echo $CPPFLAGS
    echo $CFLAGS
    echo $CC_C
    echo "===="
    test_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
}

echo是我加的,发现用到了$CFLAGS,猜测是用的shell环境的变量,新起一个终端,env | ag "mssse3"看了一下,发现确实是这样,然后才联想到conda,注释掉conda的那段zshrc代码,发现问题解决!

反过头来看,其实应该能更早地定位到问题点的,刚开始的时候没有认真看,认真想,为啥会报不支持march=core2的原因,觉得是自己编译脚本写的有问题,现在看来,要是当时能耐心去追追configure,应该早就能解决了。 I'm so vegetable! 😂

singlepig commented 4 years ago

https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html#installing-in-silent-mode

conda init zsh会加入以下这段代码。

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/singlepig/miniconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/singlepig/miniconda/etc/profile.d/conda.sh" ]; then
        . "/Users/singlepig/miniconda/etc/profile.d/conda.sh"
    else
        export PATH="/Users/singlepig/miniconda/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

就是这段代码的锅,会往你的shell里加料!!