25

After upgrading xcode to 8.0, my application project build with error for device target but building successfully for simulator.

Error is like:
ld: library not found for -lcrt1.3.1.o

What does the solution for this error.

1

4 Answers 4

54

After spending lots time, i finally got the reason for this error.

Error: ld: library not found for -lcrt1.3.1.o

Solution: If your project source have deployment target from iOS 5.0 then change it to iOS 6.0 or later and your error will be fix. Now that work fine for device too.

Hurray!!!

8
  • 2
    This helped me out with a very old app I was trying to get running again. Thanks! Commented Oct 16, 2016 at 1:52
  • This did not fix the same problem for me. Anybody knows of a different solution?
    – fishinear
    Commented Oct 18, 2016 at 17:17
  • Sorry, it's fixed now. I had to change the deployment target in both the project and the target settings.
    – fishinear
    Commented Oct 18, 2016 at 17:32
  • 1
    You saved my day, Thanks! :)
    – aareeph
    Commented Oct 24, 2016 at 5:44
  • Considering my app was still running on a first gen iPad it was a little bittersweet to make this change. But it did fix the issue.
    – Vagari
    Commented Oct 26, 2016 at 14:59
18

crt1.3.1.o is a library that was included in older iOSes (and thus, their SDKs) but is no longer present in newer SDKs.  However, when the project's Deployment Target is set to an older iOS (<6.0, as @Sandy has found), Xcode still tries linking against it.

To keep supporting iOS 5.x in newer Xcodes, one only needs to copy crt1.3.1.o from an older Xcode to the appropriate …/usr/lib/ dir in the newer Xcode.  Xcode will only use crt1.3.1.o if the Deployment Target is <6.0— for projects with a Deployment Target ≥6.0 crt1.3.1.o remains unused and the resulting linked binary is identical to what it was pre-…/usr/lib/crt1.3.1.o-addition.

To get a newer Xcode to properly link a project with a iOS 5.x Deployment Target:

  1. Download an older Xcode that still has crt1.3.1.o from https://developer.apple.com/downloads/.

    I used Xcode 5.1.1, though any Xcode that has iOS 5.x support should work (which, according to Wikipedia should be Xcode 4.2-6.4).

  2. Open the Xcode .dmg and on the disk image, locate the file at /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS….sdk/usr/lib/crt1.3.1.o.

    Since I used Xcode 5.1.1, mine was at …/iPhoneOS7.1.sdk/usr/lib/crt1.3.1.o.

  3. Copy to the same Xcode.app-relative directory in your newer Xcode: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/crt1.3.1.o.

    My newer-Xcode at time of writing is the latest release, Xcode 8.1 (which out-of-the-box includes the iOS 10.1 SDK and downloadable iOS Simulator support back to iOS 8.1).


Note that you'll need to re-perform these steps after each Xcode upgrade, since the standard Xcode update process is to just blow away Xcode.app and everything contained within with the updated Xcode.app.

Also note that I've successfully tested this using Xcode 8.1 to produce an app with a Deployment Target of iOS 5.0 that'll run on both my iOS 10.1.1 iPad Air 2 & my iOS 6.1.3 iPhone 4S.  I have not, however, submitted a build using this process to the iOS App Store.  While it's unlikely that Apple's certification would have a problem with this (since it is after all their own iOS crt1.3.1.o library; and since there is no other way to build an app against the latest SDK while still supporting iOS back to 5.x, which is almost certainly something that some enterprise clients are still doing), I can't make a firm promise here.

1
  • Awesome! I had both Xcode and Xcode_7_3, and performed this: sudo cp /Applications/Xcode_7_3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/crt1.3.1.o /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/, and it solved the problem!!
    – ishahak
    Commented Jun 16, 2017 at 15:17
0

remove the -lPods-(someCocoaPod) lines in the 'Other Linker Flags' list BUT only if $(inherited) is at the top. At first I was unsure, but the reassuring sign was that I still saw references to my cocoapods when I left the edit mode(inherited). I tested in debug and release, both of which were giving me errors, and the problem was immediately resolved

0

Instead of using the libraries from an older Xcode install, you can also just recompile them from sources: https://github.com/mringwal/csu-ios

Not the answer you're looking for? Browse other questions tagged or ask your own question.