Very simple setup:
Created a static library from a set of object files compiled with -target x86_64-apple-darwin20.1.0 then into a static library with ar and ranlib.
Did the same again with -target arm64-apple-darwin20.1.0
So now have two static libraries, one for Intel, one for Apple Silicon.
Combined them into a universal binary with lipo -create and checked it with lipo -archs. Everything looks perfect.
However when I set my Xcode project to link against this library it will only work for the arm64 build. If I set to an x86 build it says the static library is arm64 only which is clearly utter rubbish.
Anyone any idea what the issue is here? Seems that Xcode is unable to use universal binary libraries but that's clearly also got to be wrong, so why isn't it selecting the correct library architecture?
Thanks.
Post
Replies
Boosts
Views
Activity
On an M1 MBPro with XCode 12.3 / Big Sur 11.1......
If I build a binary for arm or rosetta, no warnings.
If I build a binary for 'any Mac' ie a universal binary, I get warnings of directories not found in the derived-data area. The binary is still built.
I can't believe this is the case with all universal binary builds as it's surely inconceivable that Apple could have missed such an obvious bug during testing.
Anyone else seeing these warnings and any settings that solve the issue?
I've got a makefile that creates a library of object files using "ar r mylib.a myobj1.o myobj2.o" etc.
Then I link with "gcc main.o mylib.a -o myexe" and I get the error above.
Clear the error is complete garbage - it's complaining that I'm attempting to link with the architecture I've built for which is what you're supposed to do this isn't an error anyway!
If I link directly with the object files it all works fine, so those objects are OK as is everything else.
Something about putting them in a static library seems to hit a bug in ld therefore - evidenced by the garbage error message.
The only other example I've found of this on google was 'fixed' by the poster using a more up-to-date version of the application he was compiling, so no help in what was the cause nor fix for the error.
Anyone else come across this? Any thoughts on how to debug it further?
Thanks.