I’m trying to create a universal binary for a MacOS build, and I need my dependencies to be universal as well.
After trying to figure out how to cross-compile myself, I eventually learned that SDL2’s build-scripts directory has a clang-fat.sh file. It worked great to create an SDL2 library:
$ file mac/lib/*
mac/lib/libSDL2-2.0.0.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
mac/lib/libSDL2-2.0.0.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
mac/lib/libSDL2-2.0.0.dylib (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64
...
However, a similar script does not exist in SDL2_image. If I try to use SDL2’s script to configure and build SDL2_image, I get an error:
$ ./configure CC="sh ../SDL2-2.32.8/build-scripts/clang-fat.sh" --prefix=/Users/[my_username]/Projects/Tools/CustomLibs/mac && make && make install && rm -rf arm64 x64
...
+ shift
+ test x '!=' x
+ clang -arch x86_64 -mmacosx-version-min=10.9 -DMAC_OS_X_VERSION_MIN_REQUIRED=1070 -I/usr/local/include -mmacosx-version-min=10.9 '-DPACKAGE_NAME="SDL2_image"' '-DPACKAGE_TARNAME="SDL2_image"' '-DPACKAGE_VERSION="2.8.8"' '-DPACKAGE_STRING="SDL2_image' '2.8.8"' '-DPACKAGE_BUGREPORT="https://github.com/libsdl-org/SDL_image/issues"' '-DPACKAGE_URL=""' -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 '-DLT_OBJDIR=".libs/"' -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=8 -DSDL_BUILD_MICRO_VERSION=8 '-DPACKAGE="SDL2_image"' '-DVERSION="2.8.8"' -DUSE_STBIMAGE=1 -DLOAD_JPG=1 -DLOAD_PNG=1 -DLOAD_BMP=1 -DLOAD_GIF=1 -DLOAD_LBM=1 -DLOAD_PCX=1 -DLOAD_PNM=1 -DLOAD_SVG=1 -DLOAD_TGA=1 -DLOAD_XCF=1 -DLOAD_XPM=1 -DLOAD_XV=1 -DLOAD_QOI=1 -DSDL_IMAGE_SAVE_PNG=1 -DSDL_IMAGE_SAVE_JPG=1 -I. -I./include -g -O2 -I/Users/[my_username]/Projects/Tools/CustomLibs/mac/include/SDL2 -D_THREAD_SAFE -Wall -fvisibility=hidden -c -o examples/showimage-showimage.o examples/showimage.c
../SDL2-2.32.8/build-scripts/clang-fat.sh: line 27: test: too many arguments
clang: error: no such file or directory: '2.8.8"'
make[1]: *** [examples/showimage-showimage.o] Error 1
make: *** [all-recursive] Error 1
I’m trying to debug it, but I wonder if clang-fat.sh isn’t meant to work universally across all SDL2_* libs and so I shouldn’t be trying to make it work and instead focus my efforts elsewhere.
Does anyone know?