Wednesday, March 21, 2012

Never do this:

Rename libc++.1.dylib (in /usr/lib) to something other than libc++.1.dylib. I wanted to install a fresh svn build of libc++ on my home computer. I figured I wanted to keep the original dylib file around just incase anything went horribly wrong (TM). The irony? Renaming libc++.1.dylib basically made my whole machine fail. Internet stopped working, Finder stopped working, spotlight stopped working, launchd crashed on reboot causing my computer to hang, and who know what else was broken because of it.

In hindsight, I guess it makes sense that renaming libc++.1.dylib would cause a lot of stuff to crash since libc++ is a dynamically loaded library. Though I always thought that when a dylib was loaded, it was somehow copied into the resident memory of the application. I guess not.

It does make me wonder though... what IS the correct way to install libc++ if not to replace the file? libc++'s website suggests creating links in /usr/lib but goes on to say "either way to should work" (and then never goes on to say what that other way is..). Hum.

And just to document what I did to fix it:

  1. Booted into single user mode (held command-s during reboot).
  2. Saw a diagnostic message saying that stuff crashed because libc++.1.dylib was missing. This is when I realized that renaming libc++.1.dylib did have such catastrophic effects. 
  3. Rebooted into recovery mode (held command-r during reboot).
  4. cd up several directories until I found "Volumes"
  5. cd into Volumes/Macintosh\ HD/usr/lib
  6. renamed the file to libc++.1.dylib (using the 'mv' command).
  7. Rebooted normally, and prayed that this would fix it
  8. And it did!
Hopefully I can now figure out the correct way to install libc++ >.<

No comments:

Post a Comment