28

Just upgraded to Snow Leopard, installed Xcode 3.2, then installed iPhone SDK 3 for SL.

In a project, I now get the following error on build:

ld: library not found for -lcrt1.10.6.o

I've searched around the net, but nothing helpful can be found.

3
  • 1
    Thanks everyone for the answers. I ended up backing out to Leopard and then doing a full reinstall of SL, Xcode, SDK. I dont get the issue now, so I cant use anyone's advice :) But if this comes up again I will reference this. I am wondering if it is because last time, I made a change in the proj settings from GCC to LLVM (I wanted to try the 'new' compiler :). I did not do that this time.
    – kindaran
    Commented Sep 4, 2009 at 19:03
  • 1
    How did you back out to Leopard? Time Machine?
    – Elliot
    Commented Oct 28, 2009 at 12:20
  • See: stackoverflow.com/questions/10941247/…
    – kenorb
    Commented Apr 19, 2013 at 8:45

12 Answers 12

15

Edit Project Settings -> In the build tab -> For Mac OS X Deployment Target, change it to 10.5 for XCode 3 (not 10.6 even if on 10.6) and see if that helps.

For XCode 4, you'll need to set it to 10.6

P.S. Make sure you set that for all targets, not just release or debug. (if you didn't, one would fail, the other wouldn't)

0
11

Add the following to ~/.profile (for Mac OS X 10.5):

export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include
export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib
0
6

I was able to fix this problem by adding the following to my Makefile:

CFLAGS="$(OTHER_CFLAGS) -mmacosx-version-min=10.5"
LDFLAGS="$(OTHER_LDFLAGS) -mmacosx-version-min=10.5"

Ostensibly, this is only required when building outside of Xcode. This problem frustrated me long enough that I figured it would be useful to share my experience here.

1
  • Yeah, this does it for me, too. Commented Sep 10, 2010 at 12:45
3

It looks like you're picking up libraries from /usr/lib, which is wholly inappropriate for the iPhone SDK. I would assume you've changed your build settings to add /usr/lib to the library search paths. This should be completely unnecessary in the first place, as /usr/lib is in the compiler's standard search paths, but if you need to have a modified search path like this, make sure to use $(SDKROOT)/usr/lib instead.

3
  • I'll have a look. Didnt change anything so I guess it was like that previously.
    – kindaran
    Commented Sep 1, 2009 at 23:59
  • Being the noobie person I am, I am looking in Project Settings and not seeing something obvious to change. Need a bit of help there.
    – kindaran
    Commented Sep 2, 2009 at 0:04
  • Get info on each library in your project. Make sure it's relative to the SDK. Also double-check if you've set the Library Search Paths setting on your project or target - if you have, make sure it doesn't include /usr/lib. Commented Sep 4, 2009 at 1:42
2

Setting deployment target to compiler defaults solved the problem. Don't change anything else.

2

The compiler normally uses crt1.o combined with crt[i/n].o and crt[begin/end].o to support the constructors and destructors (functions called before and after main and exit).

This error could be caused by this missing library file for the specific deployment target.

First, do some investigation, like:

  1. List all your deployment targets:

    ls -la /Developer/SDKs
    
  2. Find which crt1 libraries do you have for which environment

    find /Developer/SDKs -name crt1\*
    

    You could see something like:

    /Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.10.5.o
    /Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.o
    /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.5.o
    /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o
    /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.o
    

As you can see in above example, crt1.10.6.o is missing for MacOSX10.5.

Solution 1

You can solve that by creating the link to the missing file pointed to the other environment, or you could change your deployment target. E.g.

ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o /Developer/SDKs/MacOSX10.5.sdk/usr/lib/

Other reason why it's missing, is that you could have different gcc installed in your system. E.g.:

which gcc
xcrun -find gcc
brew list | grep gcc; brew list gcc47

Solution 2

So when you're compiling using make, you can actually specify the right compiler by CC variable. E.g.

CC=/path/to/gcc-3.4 make

Solution 3

What you can also try is specifying the right target deployment environment variable for gcc, e.g.:

export MACOSX_DEPLOYMENT_TARGET=10.5

If this works, then you can add this library path to your shell profile (~/.profile). E.g.

export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include

export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib

Or by temporary exporting them.


How to test

Create the example conftest.c file with the following code:

#ifdef __GNUC__
  yes;
#endif

And try to compile it via:

gcc conftest.c
cc conftest.c
cc conftest.cc conftest.c
1

Wasted few hours on this one...

Interestingly, for me the problem was only for Simulator-Debug. It wasnt complaining for Simulator-Release or Device Debug/Release!

anyway, Changing Deployment Target to 10.5 solved this for me!!

1

This problem solved by setting Mac OS X Deployment Target to 10.5 and after this set back to Compiler Default :)

1

I had this problem when I was using Xcode 4 on one machine and Xcode 3.2.6 on another. The two versions are supposed to be able to swap .xcodeproj files between them but I found that in the project.pbxproj file (inside the .xcodeproj directory), there were still a couple of places that read:

MACOSX_DEPLOYMENT_TARGET = 10.6;

I quit Xcode and went and changed the three occurrences to:

MACOSX_DEPLOYMENT_TARGET = 10.5;

After reopening the project, I could build again. Whew!

1

I had the same error message, none of the above solutions worked for me. I resolved it by deleting the *.pbxuser and *.mode1v3 files inside the xcodeproj file.

  1. Control/click the xcode *.xcodeproj file
  2. Select the "show package contents" option from the menu
  3. A window will open with the contents
  4. Delete the pbxuser/mode1v3 files that start with your user name
  5. Rebuild the project
1

I had the same issue in a Fortran Makefile. Added the following option after the compiler (For OSX 10.5):

-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib

e.g.,

g77 -L/Developer/SDKs/MacOSX10.5.sdk/usr/lib

Now the compiler will find the library you want !

0
Add the following to ~/.profile (for Mac OS X 10.5):

export C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/include

export LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/lib

Given Kirandan's limited scenario (Snow Leopard, Xcode 3.2.1, iphone, library path error), Stefan's answer (above) worked for me, except my exception was with 10.5 (-lcrt1.10.5.o).

Elsewhere, I'd seen an answer by Gabor Cselle (author of reMail), and he fixed this specific issue by using a symbolic link (someone referenced this page, by the way), but he noted this was not the best way.

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