Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How come GCC compiler isn't working in Terminal?

Hello,


Whenever I try to compile my C code (just a simple helloworld.c) via Terminal I get the following error:


-bash: gcc: command not found


I found some information using Google and I did install Xcode. When I browse to usr/bin the files cc and gcc link to gcc-4.2. So everything seems to be right except for one thing: it doesn't work.


Does anybody know what I'm doing wrong? I guess it's something simple but I can't put my finger on it.


Thanks in advance,


svdv22

iMac, Mac OS X (10.6.7), I'm running Xcode 3.2.5

Posted on May 17, 2011 5:48 AM

Reply
6 replies

May 17, 2011 7:42 AM in response to Frank Caggiano

Thank you for your reply.

I'm not too much into Terminal (as a matter of fact, used it for the first time right now) so what I tried is this:


Using "cd /developer/usr/bin/" to open /usr/bin/gcc as a folder

result: "Not a directory" (which is correct; it isn't).


/usr/bin/ is a directory. So I opened that in the terminal and tried to ran 'gcc'

result: "No application knows how to open /Developer/usr/bin/gcc."

I get the same message when I try to open "gcc-4.2".


Is this what you wanted me to try? Or did I misunderstand you?

May 17, 2011 10:48 AM in response to svdv22

svdv22 wrote:


Using "cd /developer/usr/bin/" to open /usr/bin/gcc as a folder

result: "Not a directory" (which is correct; it isn't).

What, exactly, are you typing on the command line. When you deal with the command line, you must be absolutely precise.


For example, MacOS X, by default, uses a case insensitive file system. If you do something like:

pele:~ jdaniel$ cd /developer/usr/bin

pele:bin jdaniel$


it will work just fine, even though there is no "/developer" directory. There is "/Developer" and that is what it should use.


If you try to move into a truly non-existent directory, you should get a different error message:

pele:bin jdaniel$ cd /developer/usr/bin2

-bash: cd: /developer/usr/bin2: No such file or directory


Did you do anything non-default when you installed MacOS X? Did you do anything non-default when you installed Xcode?


You should be able to run the following from any directory. If you can't something is wrong.

pele:tmp jdaniel$ gcc --version

i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (yada, yada, yada)

May 17, 2011 11:56 PM in response to svdv22

Well something is definitely wrong. I can't recall installing anything different than the default options. When I was at home (same os and xcode) and I ran gcc --version I got a reply like Etresoft said. When I try the same on this computer I get nothing, I get: -bash: gcc: command not found.


I get the feeling I didn't install something the way it should, what do you think? 😉

How come GCC compiler isn't working in Terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.