ld error in Xcode 7 beta 5: "building for OS X, but linking in object file built for (unknown)"

My project built successfully with Xcode 7 beta 4, but with Xcode 7 beta 5 I now get this error when linking to an existing framework (pre-built i386 binary, I don't have the source code):


ld: building for OSX, but linking in object file built for (unknown)


What changed in the linker? I didn't see anything in the release notes. How can I continue to link to this framework?

Answered by Chris Campbell in 45486022

Looks like it's fixed in Xcode 7 beta 6!

I have exactly the same issue against the eSellerate EWSEmbedded.framework, but in my case against architecture x86_64. Would be great to know what settings to change to get it to build again?

There is a known regression (<rdar://problem/22165479>) that was uncovered after Xcode 7 beta 5 shipped that looks like this, but I'm not 100% certain if it is a dupe of your issue or just a similar symptom. As such, the safest thing to do is file a radar with a sample project as an attachment. Please be sure to test with Xcode 7 beta 6 when it comes out and update your radar to indicate if the issue is still present.


Thanks.

How does ld know what platform (OS) the object file was built for? I'm assuming this is a new capability (maybe new in Xcode 7 beta 5?), and all existing binaries don't have whatever metadata is necessary for ld to make that determination? Is there a way to populate that metadata on an existing binary? The man page for "ld" is silent about such things. I tried to poke through the LLVM source code, but didn't get very far.



FYI, I filed rdar://problem/22212562

FYI, I replaced the "ld" binary in Xcode 7 beta 5 with the "ld" binary from Xcode 7 beta 4, and it has worked around this problem for me. At least, I can build my app again. Hoping for a real fix in beta 6, of course.


/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld

Hi Chris,


Filed a Radar as well and thank you for taking the time to post the workaround, much appreciated. I did not have the beta 4, but replaced it with the ld from Xcode 6 and is now working again. Like yourself I just wanted to continue to be able to build my app and continue testing.

FYI, you can also replace it with the 'ld' from the beta 6 package of the command line tools.

/Library/Developer/CommandLineTools/usr/bin/ld

Accepted Answer

Looks like it's fixed in Xcode 7 beta 6!

I am still getting the same error on Xcode 7 beta 6. Is it working for you?

boost(thread_future.o), building for iOS simulator, but linking in object file built for OSX, for architecture x86_64

I use Xcode 7 beta 6 and I still get an error when trying to use Chilkat libraries:


ld: in /Users/.../Libraries/Chilkat/chilkat-9.5.0-ios9/lib/libchilkatIos.a(CkoBaseProgress.o), building for iOS simulator, but linking in object file built for OSX, for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Hi Jeremy,


I am experiencing this issue with XCode 7 Beta 6 as well when running on OSX 10.10, but only when I compile for the Mac target in my app. My iOS targets seem to work OK and the also link with this same library that is giving errors when building for Mac.


I get the following error message:

ld: in libSuperpoweredAudio.a(SuperpoweredAdvancedAudioPlayer.o), building for OSX, but linking in object file built for iOS, for architecture x86_64


I filed radar# 22544558

really? it seems broken in the GM seed i just downloaded ⚠

Xcode GM still shown the same error.


(null): Building for iOS simulator, but linking in object file built for OSX, file ... for architecture x86_64


ld: building for iOS simulator, but linking in object file built for OSX, file '/Users/***.o' for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


When are you going to fix issue?

when I went to try this, ld became unable to load any system frameworks, e.g.:


ld: framework not found Foundation


note: I replaced the Xcode 7 GM ld with the Xcode 6.4 ld.

I experienced the same issue with Xcode 7 GM


ld: in libSuperpoweredAudio.a(SuperpoweredAdvancedAudioPlayer.o), building for OSX, but linking in object file built for iOS, for architecture x86_64


I have not found a workaround, yet

I am having a similar issue with the GM. I don't know if it existed before as I was waiting for the GM before using Xcode 7.


ld: in /Users/dctrotz/Projects/MyAppName/src/3rdParty/openssl/lib/libcrypto.a(cryptlib.o), building for iOS simulator, but linking in object file built for OSX, for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld error in Xcode 7 beta 5: "building for OS X, but linking in object file built for (unknown)"
 
 
Q