Weird "C compiler cannot create executables" error

After upgrading to Mac OS X Lion 10.7.3 I wanted to install pdnsd from homebrew.
When I run "brew install pdnsd" (or any homebrew formula), I got "checking for C compiler default output file name... configure: error: C compiler cannot create executables".

To solve this problem you need to:

  1. Install XCode from app store.
  2. Install Command Line Tools in XCode Prefenences -> Downloads.