Fixing ld: warning: in /usr/local/lib/libz.dylib, file is not of required architecture 4

Posted by Sheldon Finlay on January 08, 2010

I banged my head on this stupid problem for months. It all came about after upgrading my Macbook from Leopard to Snow Leopard (OSX 1.6). I was plagued with this error here and there when I wanted to compile certain software (namely imagemagick and mysql) or install certain native Ruby gem. It was a nightmare, but it seemed I would have to live with it, until I could find the time to reinstall Snow Leopard from scratch.

Google reveals very little useful information for dealing with this error. Everyone seems to have the problem, and yet fixes seem quite elusive. I finally hit upon a fix that worked for me and I’ll share it here in case the solution also works for others. First thing you’ll want to do is install xCode, the developer SDK from Apple. Download the most recent version from the Apple Developer site, as the version on disk might be old. You’ll need the OSX 10.6 libraries. After xcode is installed go to the directory that the problemed libz.dylib file is found and rename it so you have a backup in case things get messed up worse and you need to restore it:

cd /usr/local/lib/libz.dylib
sudo mv libz.dylib libz.dylib.original

Now, when you installed xCode it should have also installed a recent version of libz.dylib in among the SDK files. So the next step is to copy that version of the file to replace the file we just renamed.

sudo cp -rf /Developer/SDKs/MacOSX10.6.sdk/usr/lib/libz.dylib .

That’s it. Go ahead and try to install that pesky ruby gem (rmagick) that wasn’t installing or compile ImageMagick. If you are lucky like me, it should work. I hope this saves some folks a lot of hair pulling. Let me know how it goes!

This may also work for some other dylib files that are problematic such as libexpat.dylib. Just take a look in the lib directory of the OSX 10.6 SDK and see if the file exists. Remember to things up before replacing swapping in the new files.

MobileMe iDisk Not in Sync 2

Posted by Sheldon Finlay on December 17, 2009

mobilemeI love MobileMe. It complements my workflow in countless ways. I particularly like using the iDisk to sync a selection of files between multiple computers. It’s nice to be able to work on a file during the day on one computer and come home and work on it on another computer without having to copy the file. However, every once in a while it hits a snag and no matter how many times I attempt to manually sync, the files just don’t update and I see a message in the bottom of the finder that says “iDisk not in sync”. So what now? We’ll it’s quite easy to get back up and running. You just need to follow these steps:

  1. Go to MobileMe under System Preferences.
  2. Under the iDisk Tab click “Stop” to disable iDisk syncing. This will create a local copy of your files on your desktop called “previous local idisk”.
  3. Next, go to the Account tab and click Sign Out.
  4. Now sign back In with an incorrect username and password. Anything will do. You should get an error message.
  5. Next, sign back into your Mobile Account with your correct username/password.
  6. Go back to the iDisk tab and Turn On iDisk Syncing.
  7. Now the iDisk icon should be back on your desktop. If you open it, it should start showing that it’s syncing. It may take a while depending upon how many files you have on your iDisk.
  8. Finally, you may have to manually put any recently updated or created files from your “previous local idisk” into your iDisk.

And that should be it. You might need to repeat this process on any computer that you sync to your iDisk which is having problems syncing.

Syncing dotfiles using your MobileMe iDisk

Posted by Sheldon Finlay on April 11, 2009

If you are developing on a Mac, you no doubt use dotfiles. If you are like me, you are constantly tweaking your dotfiles, adding in new aliases and functions or whatever to help streamline your workflow. I have two computers I develop on, a Macbook and a Mac Pro desktop. Switching between them is often frustrating because my dotfile customizations I use on one are not found on the other until I set them up. I knew there had to be a better way to keep my ever-changing dotfiles synced.

I have a MobileMe account with Apple and already use it to synchronize my life between my two Macs and my iPhone. It rocks and is well worth the subscription for the convenience it affords. This past week I started thinking about whether it would be possible to sync other files between my Macs. I decided to start with my dotfiles as a simple and easy proof of concept. Here’s how I did it:

The computers you’ll be syncing must use the same MobileMe account since you’ll be using the iDisk as the vehicle of synchronization. The first thing you want to do is enabled iDisk sync on the computers.  iDisk sync can be enabled in MobleMe settings in System Preferences. Choose the iDisk option and set iDisk Sync to On and choose Automatically as the update choice.  This will enable your iDisk files to be synced and downloaded to your computer regularly so you can access them offline. Otherwise, all your iDisk files are stored in the cloud and you wouldn’t have access to your dotfiles if you were offline.

iDisk sync should be on and set to automatic.

Open your iDisk on one of the computers and create a permanent location for your dotfiles. For this tutorial I’ll be using what I have set up which is have a folder called Misc and inside there I have a folder called Dotfiles. You can set it up however you like, as long it it’s permanent. If you move or rename this location you will need to redo the symlinks.

Next choose which computer’s dotfiles will be the ones you want to use and move them to your chosen folder on your iDisk. By default, dotfiles are invisible in the Finder, so you’ll need to use the Terminal. The iDisk should be found under /Volumes/iDisk:

mv .profile /Volumes/iDisk/Misc/Dotfiles/.
mv .bashrc /Volumes/iDisk/Misc/Dotfiles/.
mv .bash_profile /Volumes/iDisk/Misc/Dotfiles/.
mv .bash_login /Volumes/iDisk/Misc/Dotfiles/.
mv .gitconfig /Volumes/iDisk/Misc/Dotfiles/.
mv .gitk /Volumes/iDisk/Misc/Dotfiles/.
mv .gitignore /Volumes/iDisk/Misc/Dotfiles/.
mv .irbc /Volumes/iDisk/Misc/Dotfiles/.
mv .rails-plugin-sources /Volumes/iDisk/Misc/Dotfiles/.

These are just some of the dotfiles I like to keep synced (my list goes on and also includes some non-dotfiles in my root directory). Yours will no doubt be different depending upon which shells and tools you use. The world is your oyster here, so don’t hold back.

Now that your dotfiles have been moved over it’s time to link to them using a symbolic link. A symbolic link is basically an alias or pointer to an actual file located somewhere else:

ln -s /Volumes/iDisk/Misc/Dotfiles/.profile .
ln -s /Volumes/iDisk/Misc/Dotfiles/.bashrc .
ln -s /Volumes/iDisk/Misc/Dotfiles/.bash_profile .
ln -s /Volumes/iDisk/Misc/Dotfiles/.bash_login .
ln -s /Volumes/iDisk/Misc/Dotfiles/.gitconfig .
ln -s /Volumes/iDisk/Misc/Dotfiles/.gitk .
ln -s /Volumes/iDisk/Misc/Dotfiles/.gitignore .
ln -s /Volumes/iDisk/Misc/Dotfiles/.irbc .
ln -s /Volumes/iDisk/Misc/Dotfiles/.rails-plugin-sources .

When you do an ‘ls -al’ in Terminal you should see your newly created dotfile symlinks. Log out of Terminal and log back in and check to see if your environment is working. Test your aliases, etc. If you set everything up correctly, things should work as they always have. If not, check your work.

Now that the first computer is set up and dotfiles are on your iDisk you can go ahead and set up any other computers you want to synchronize. This time you will just be deleting the dotfiles from the computer:

rm -f .profile .bashrc .bash_profile .bash_login .gitconfig .gitk .gitignore .irbc .rails-plugin-sources

Once they are deleted your can repeat the symlink step you did on the first computer. One thing to watch for: make sure your iDisk on both computers have synced. They will sync automatically every 10 minutes or so, but if you’re real quick, the dotfiles might not show up yet on the other computers. Either go get a cup of coffee or try doing a manual sync on all your computers, starting with the first one you set up. Once they are synced, do your symlinks and test to make sure everything works.

That’s it. You’re done! Now, if you make a dotfile change on any of the computers, it will be automatically synced to the others. It’s a very simple thing, but a huge convenience.