How can I find out if I have Xcode commandline tools installed?

I need to use gdb.

ps-MacBook-Air:AcoustoExport pi$ gdb
-bash: gdb: command not found

ps-MacBook-Air:AcoustoExport pi$ sudo find / -iname "*gdb*"
Password:
/usr/local/share/gdb
/usr/local/Cellar/isl/0.12.1/share/gdb
:

and:

ps-MacBook-Air:AcoustoExport pi$ ls -la /usr/local/share/gdb
lrwxr-xr-x   1 pi    admin   30 14 Jan 22:01 gdb -> ../Cellar/isl/0.12.1/share/gdb

Not quite sure what to make this, clearly it is something installed by homebrew. I don't know why it's there, I don't know whether I could use it instead. It isn't in the search path.

So I figure I need Xcode commandline tools.

Xcode is not currently available from the Software Update server

^ my current problem exactly. Comment on that question says "you can get this error if you have them already"

But how do I check whether I have them already?


/usr/bin/xcodebuild -version

will give you the xcode version, run it via Terminal command


First of all, be sure that you have downloaded it or not. Open up your terminal application, and enter $ gcc if you have not installed it you will get an alert. You can verify that you have installed it by

$ xcode-select -p
/Library/Developer/CommandLineTools

And to be sure then enter $ gcc --version

You can read more about the process here: Xcode command line tools for Mavericks


if you want to know the install version of Xcode as well as Swift language current version:

Use below simple command by using Terminal:

1. To get install Xcode Version

 xcodebuild -version

2. To get install Swift language Version

swift --version

I was able to find my version of Xcode on maxOS Sierra using this command:

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version

as per this answer.


Thanks to the folks on Freenode's #macdev, here is some information:

In the old days before Xcode was on the app-store, it included commandline tools.

Now you get it from the store, and with this new mechanism it can't install extra things outside of the Xcode.app, so you have to manually do it yourself, by:

xcode-select --install

On Xcode 4.x you can check to see if they are installed from within the Xcode UI:

enter image description here

On Xcode 5.x it is now here:

enter image description here

My problem of finding gcc/gdb is that they have been superseded by clang/lldb: GDB missing in OS X v10.9 (Mavericks)

Also note that Xcode contains compiler and debugger, so one of the things installing commandline tools will do is symlink or modify $PATH. It also downloads certain things like git.