Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I find out if I have gcc installed on my machine?

I am trying to run CodeRunner, but it isn't responding. I know you have to have gcc installed in order for it to work properly. I do have Xcode 4.0.2 installed (from what I've read, if Xcode is installed then you already have gcc).

share|improve this question
1  
Should be on superuser or elsewhere; this isn't a question about programming. –  Seth Johnson Apr 30 '11 at 2:30
add comment

migrated from stackoverflow.com Apr 30 '11 at 2:47

This question came from our site for professional and enthusiast programmers.

5 Answers

  1. Type gcc at the Terminal prompt. If it says "command not found", you don't. Otherwise, you do.
  2. If that fails, then install from your OSX CD.
share|improve this answer
2  
Technically, that is testing to see if gcc is in his PATH. Typing gcc could fail even if it is installed. –  objectiveGeek Apr 30 '11 at 2:31
    
@objectiveGeek - Yes, but if it's not in his $PATH it's not going to be useful, as most scripts that rely on it being "installed" will probably rely on it also being in $PATH and thus callable as gcc instead of /my/dumb/install/location/gcc –  Chris Lutz Apr 30 '11 at 2:33
    
@Ernest: It gave me 'no input files'. Does this mean its installed. I'm assuming yes? –  willis0924 Apr 30 '11 at 2:36
    
@wilis0924: Yes. Also try gcc -v to get the installed version number. –  Drew Hall Apr 30 '11 at 2:37
    
@Chris Installing gcc under /usr/bin is optional in Xcode’s installer. –  Bavarious Apr 30 '11 at 2:38
show 3 more comments

You could just try to see if a gcc executable is present. Try:

ls /usr/bin/gcc*
share|improve this answer
    
Better with whereis gcc or which gcc. –  jweyrich Apr 30 '11 at 2:38
    
which only works if the PATH is correctly configured. –  highBandWidth Apr 30 '11 at 2:39
    
Yet, if you don't have /usr/bin in your PATH, your Mac OS is likely to be broken. –  jweyrich Apr 30 '11 at 2:42
    
If someone messed up the .bash_profile for the particular user, the PATH could be messed up while the system is ok. –  highBandWidth Apr 30 '11 at 2:45
    
I, for one, have gcc-4.7-base installed (according to synaptic package manager) but whereis/which can not find it –  puk Oct 25 '13 at 9:44
add comment

Try any terminal command, like:

$ gcc --help

If gcc isn't installed, you will often see a message with a "how to install it" note, complete with the package manager's command.

share|improve this answer
add comment

You can use "locate gcc" to find all filenames with gcc in them.

share|improve this answer
add comment

On Terminal type

gcc -v

You will get something like below

Using built-in specs.
 ......
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

This will show you version of GCC installed on your machine. If gcc is not installed then this command will not work as above

share|improve this answer
    
Can you add some more explanation of what this output means. –  ChrisF Feb 14 '13 at 11:42
    
Please check edited part –  silwar Feb 14 '13 at 11:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.