Building libopus for mac os x universal binary
Currently, the active mac hardware includes both x86_64 and arm64 architecture. Apple supports universal binaries that include support for both of these architectures, such that the appropriate code is used at runtime. In order for an application to successfully support both, all dependent libraries must also be universal binaries. Libopus is a dependent library for my application.
My build machine is x86_64, but Apple includes the compilers for both architectures in recent versions of Xcode.
For most libs (libogg, libflac, ...) the following seems to work, but it does not work for libopus:
./configure CXXFLAGS="-arch x86_64 -arch arm64" CFLAGS="-arch x86_64 -arch arm64"
make -j8
sudo make install
result: checking How to get X86 CPU Info... configure: error: no supported Get CPU Info method, please disable run-time CPU capabilities detection or intrinsics
Then I tried:
./configure --disable-rtcd CXXFLAGS="-arch x86_64 -arch arm64" CFLAGS="-arch x86_64 -arch arm64"
make -j8
result: Undefined symbols for architecture arm64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)