0

I'm trying to build a universal binary of ffmpeg on MacOS, by compiling it twice (for arm64 and x86_64) and then using the lipo tool to combine the resulting binaries. I'm on an M1 Mac, so uname -m returns arm64 on my machine.

When running the configure script like so:

./configure --arch=x86_64

It outputs:

install prefix            /usr/local
source path               .
C compiler                gcc
C library                 
ARCH                      c (generic)
...

And after running make, inspecting the built binaries with lipo -archs reveals that it's building them for arm64.

The result is the same if I add --enable-crosscompile to the configure call.

Based on this post, I also tried --arch=x86, but that had the exact same result, configure script displayed arch as c (generic) and inspecting artefacts with lipo shows they are built for arm64 architecture.

Does anyone have any ideas? Why is the configure script just refusing to build for x86_64?

John Bollinger
  • 160,171
  • 8
  • 81
  • 157

1 Answers1

0

You can speify -cc to make clang compile x86_64 binary. Try:

./configure --enable-cross-compile --prefix=./install_x86_64 --arch=x86_64 --cc='clang -arch x86_64'

Note: don't forget to clear the outdated files by

make distclean

By the way, I have successfully built universal binrary of FFmpeg, you can refer to my build scripts. make_compile.py compile both x86_64 and arm64 binraries, and make_universal.py use lipo to generate universal binrary.

Reference

https://ffmpeg.org/platform.html

https://github.com/FFmpeg/gas-preprocessor

ColorsWind
  • 16
  • 1
  • 1
  • Thank you so much! This worked. I was pulling my hair out trying to wrangle FFmpeg's configure script, I really wish they would just use Cmake... but this worked, thanks again! – Ben Vining Apr 13 '22 at 13:30
  • On M1, using configure for cross compiling for static x86_64 libraries, I get the error : nasm/yasm not found or too old. Use --disable-x86asm for a crippled build. Any idea ? I looked at your repo which is amazing, but you didn't seem to have that problem ? – Théophane Aug 27 '23 at 17:07
  • Oh nevermind sorry, I found [this random answer](https://stackoverflow.com/a/64110269/7360943) which simply suggests installing yasm with brew ```brew install yasm``` – Théophane Aug 27 '23 at 17:16