I was having problems compiling gems from the terminal in my Mac last week. After further investigation and some Googling, I found out that it was because Xcode 4.3 now uses the LLVM-based gcc and not all native gems support it. I then installed the Command Line Tools for Xcode hoping that would solve the problem. Unfortunately, it didn't. At least not completely.
After some more digging around, I came to realize that
/usr/bin/gcc, which is what gets used by default, is actually symlinked to
/usr/bin/llvm-gcc-4.2. I tried setting
CC=/usr/bin/gcc-4.2 whenever I installed gems, but somehow that gets lost along the way. Some suggested that I downgrade to Xcode 4.1 or even uninstall Xcode altogether. However, in my case, I use Xcode every now and then so that was not an option.
Thankfully, I came across a suggestion in StackOverflow which said that I create symlinks to the classic gcc and make sure it's accessed first when I'm in the terminal. Here's how I did it:
First, I created a hidden folder in my home directory:
Next, I created symlinks in
Note that in order for those to work, the Command Line Tools for Xcode should be installed. You can do that via direct download or through Xcode's Downloads preference pane.
Next, I edited
~/.bash_profile and appended the following:
The above ensures that my symlinks are used and not
/usr/bin/gcc. I then reloaded
After this, all native gems compiled successfully.