First, install XCode via the App Store (free software) and install the command line tools by typing in a Terminal window:

   xcode-select --install