在 apple M1 上构建 x264 失败,找不到可用的 C 编译器

build x264 failed on apple M1, No working C compiler found

  1. Apple M1,叮当声
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: arm64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  1. x264version x264-snapshot-20191217-2245

  2. 配置

 ./configure --prefix=/tmp/  --enable-static
  1. config.log
checking for -Werror=unknown-warning-option... yes
checking for -mdynamic-no-pic... yes
x264 configure script
Command line options: "--prefix=/tmp/" "--enable-static"

checking whether gcc works... no
Failed commandline was:
--------------------------------------------------
gcc conftest.c  -Wall -I. -I$(SRCPATH) -mdynamic-no-pic -arch armv7  -Werror=unknown-warning-option    -lm -arch armv7 -o conftest
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a, missing required architecture armv7 in file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a (5 slices)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libm.tbd, missing required architecture armv7 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libm.tbd (3 slices)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture armv7 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd (3 slices)
ld: dynamic main executables must link with libSystem.dylib for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--------------------------------------------------
Failed program was:
--------------------------------------------------
int main (void) {  return 0; }
--------------------------------------------------
DIED: No working C compiler found.

x264源快照压缩包好久没更新了。您需要将 x264 源更新到更新版本:https://code.videolan.org/videolan/x264/

2020 年底添加了 Apple Silicon x264 支持。