Search code examples
apple-m1x264libx264

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


  1. Apple M1, clang
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. x264 version x264-snapshot-20191217-2245

  2. configure

 ./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.

Solution

  • x264 source snapshot tarballs have not been updated for a long time. You need to update x264 sources to a newer version: https://code.videolan.org/videolan/x264/

    Apple Silicon support in x264 was added at the end of 2020.