libc++ linking problem

Recently I have found programs built with libc++ have stopped working recently, producing the message:

~/temp$ ./a.out
dyld: Library not loaded: /usr/lib/libc++.1.dylib
Referenced from: /Users/caj/temp/./a.out
Reason: image not found
Trace/BPT trap

Looking at otool I see:

Load command 10
         cmd LC_LOAD_DYLIB
     cmdsize 48
        name /usr/lib/libc++.1.dylib (offset 24)
  time stamp 2 Thu Jan 1 01:00:02 1970
     current version 1.0.0

Note the ".1" in the dylib name. This is not mentioned on the instructions on the libc++ homepage. If I use an older build of both clang and libc++, on another computer (sorry for the number of changed variables) I get:

Load command 10
         cmd LC_LOAD_DYLIB
     cmdsize 48
        name /usr/lib/libc++.dylib (offset 24)
  time stamp 2 Thu Jan 1 01:00:02 1970
     current version 1.0.0
compatibility version 1.0.0

With no ".1". Is this an intentional change, or might my computer be confused? If it is an intentional change, the instructions on the libc++ homepage should be changed.

To be able to deploy many versions of the same library, the library install name must contain the version. That what all libraries in /usr/lib do.
The fact that libc++ didn't include the version was IMHO an error, and so the fix make it consistent with all other libraries.

I attached a patch to fix the doc.
I choose to create a relative symlink for the libc++.dylib to be consistent with all other symlinks in /usr/lib, but if you prefer to make it points to the compiled library directly, it can be changed.

-- Jean-Daniel

install.patch (592 Bytes)

Thanks Jean, committed revision 126222. Chris, if this isn't clear or if you still have problems just let me know and I'll get you back up.

-Howard