macOS universal static library

Howdy,

My team would like to use static libraries for our SDL based project, but there don’t seem to be any pre-built versions of the libs that are universal (i.e. have both intel and arm objects).

The macOS download from libsdl.org is a framework with a universal dynamic lib. The Homebrew install has a static lib, but it seems to be specific to the machine.

What’s the best way to get a macOS universal static library of SDL? Or should I just have two separate static libraries, one for each architecture?

Thanks,
Chuckles

For the record, I ended up using lipo to create a universal static lib from the intel and arm static libs which I manually unpacked from their respective Homebrew bottles. Seems to be working!

I also tried to build my own universal static lib using the supplied Xcode project, but the resulting lib didn’t seem to have any of the framework dependencies built into it. What I mean is that when I tried to use that locally-built static lib in my game, it generated a ton of link errors against system frameworks. I could have solved that by manually creating dependencies to the system frameworks in my game project, but that seemed like a hacky workaround, especially considering that the Homebrew built libs don’t need it. Anyone know what the difference is between the libs?

Apparently I only thought I was linking against the static libs. If you “Link Binary With Libraries” to a static library that’s in the same location as a dynamic library of the same name, then Xcode will silently link against the dynamic library instead.

So I built universal static libraries successfully two different ways, but if I’m going to use it then I have to manually add the system framework dependencies to my game. If you use the universal dynamic library then you atomically get those dependencies.

That was a lot of pain for a slight improvement in understanding. Sheesh, Apple.